void CBackgroundSound::importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot) { NLGEORGES::UFormElm *psoundType; std::string dfnName; // some basic checking. formRoot.getNodeByName(&psoundType, ".SoundType"); nlassert(psoundType != NULL); psoundType->getDfnName(dfnName); nlassert(dfnName == "background_sound.dfn"); // Call the base class CSound::importForm(filename, formRoot); // Read the array of sound with there respective filter. { _Sounds.clear(); NLGEORGES::UFormElm *psoundList; formRoot.getNodeByName(&psoundList, ".SoundType.Sounds"); if (psoundList != 0 && psoundList->isArray()) { uint size; psoundList->getArraySize(size); for (uint i=0; i<size; ++i) { TSoundInfo sound; NLGEORGES::UFormElm *psoundItem; psoundList->getArrayNode(&psoundItem, i); if (psoundItem != NULL) { // Read the sound name. std::string soundName; psoundItem->getValueByName(soundName, "Sound"); sound.SoundName = CStringMapper::map(CFile::getFilenameWithoutExtension(soundName)); // Read the environnement flag. for (uint j=0; j<UAudioMixer::TBackgroundFlags::NB_BACKGROUND_FLAGS; j++) { char tmp[200]; sprintf(tmp, "Filter%2.2u", j); psoundItem->getValueByName(sound.Filter.Flags[j], tmp); } } _Sounds.push_back(sound); } } } _DurationValid = false; }
//=============================================================================== void CWorldSheet::build(const NLGEORGES::UFormElm &item) { const UFormElm *pElt; uint size; nlverify (item.getNodeByName (&pElt, "continents list")); if(!pElt) { nlwarning("node 'continents list' not found in a .world"); } else { nlverify (pElt->getArraySize (size)); ContLocs.reserve(size); for (uint32 i = 0; i <size; ++i) { const UFormElm *pEltOfList; // Get the continent if (pElt->getArrayNode (&pEltOfList, i) && pEltOfList) { SContLoc clTmp; clTmp.build (pEltOfList); ContLocs.push_back (clTmp); } } item.getValueByName (Name, "name"); } // Maps loading nlverify (item.getNodeByName (&pElt, "maps list")); if(!pElt) { nlwarning("node 'maps list' is not found in a .world"); } else { nlverify (pElt->getArraySize (size)); Maps.reserve(size); for (uint32 i = 0; i < size; ++i) { const UFormElm *pEltOfList; // Get the continent if (pElt->getArrayNode (&pEltOfList, i) && pEltOfList) { SMap mapTmp; mapTmp.build (pEltOfList); Maps.push_back (mapTmp); } } } }
//============================================================================= void CWeatherFunctionSheet::build(const NLGEORGES::UFormElm &item) { const NLGEORGES::UFormElm *elm; uint numSetups = 0; // get list of weather setups from the form if(item.getNodeByName (&elm, "WeatherSetups") && elm) { // Get number of setups nlverify (elm->getArraySize (numSetups)); SetupNames.resize(numSetups); // For each setup for(uint k = 0; k < numSetups; ++k) { if (!elm->getArrayValue(SetupNames[k], k)) { nlwarning("Can't read weather setup from form"); } } } uint numWeights = 0; SetupWeights.resize(numSetups); // get weight of each weather setup. Setup that are not given are assumed to be 1 if(item.getNodeByName (&elm, "SetupsWeights") && elm) { // Get number of setups nlverify (elm->getArraySize (numWeights)); numWeights = std::min(numSetups, numWeights); // For each setup for(uint k = 0; k < numWeights; ++k) { if (!elm->getArrayValue(SetupWeights[k], k)) { nlwarning("Can't read weather setup from form"); } SetupWeights[k] = std::max((uint32) 1, SetupWeights[k]); } } // complete other weights if not same size std::fill(SetupWeights.begin() + numWeights, SetupWeights.begin() + numSetups, 1); // getWeatherFuncFormValue(item, VegetableMinBendIntensity, "Visual.VegetableMinBendIntensity"); getWeatherFuncFormValue(item, VegetableMaxBendIntensity, "Visual.VegetableMaxBendIntensity"); getWeatherFuncFormValue(item, VegetableMinWindFrequency, "Visual.VegetableMinWindFrequency"); getWeatherFuncFormValue(item, VegetableMaxWindFrequency, "Visual.VegetableMaxWindFrequency"); getWeatherFuncFormValue(item, VegetableMaxBendOffset, "Visual.VegetableMaxBendOffset"); getWeatherFuncFormValue(item, VegetableWindIntensityThatStartBendOffset, "Visual.VegetableWindIntensityThatStartBendOffset"); // getWeatherFuncFormValue(item, TreeMinWindIntensity, "Visual.TreeMinWindIntensity"); getWeatherFuncFormValue(item, TreeMaxWindIntensity, "Visual.TreeMaxWindIntensity"); }
//----------------------------------------------- // build : // Build the sheet from an external script. //----------------------------------------------- void CMissionSheet::build(const NLGEORGES::UFormElm &item) { // Load the descriptors. if(!item.getValueByName(Name, "Name")) debug("key 'Name' not found."); if(!item.getValueByName(Description, "Description")) debug("key 'Description' not found."); if(!item.getValueByName(RewardDescription, "RewardDescription")) debug("key 'RewardDescription' not found."); // load mission steps description for (uint i =1; i< NB_STEPS_PER_MISSION + 1;i++) { const UFormElm * stepStruct; string varName = string("step") + NLMISC::toString(i); item.getNodeByName (&stepStruct, varName.c_str()); if (stepStruct) { string stepDesc; stepStruct->getValueByName(stepDesc,"Description"); if ( !stepDesc.empty() ) StepsDescription.push_back(stepDesc); } } }// build //
//========================================================================= void CContinentSheet::build(const NLGEORGES::UFormElm &item) { Continent.build(item); const UFormElm *elm; // Load the village list if(item.getNodeByName (&elm, "Villages") && elm) { // Get number of village uint numVillage; nlverify (elm->getArraySize (numVillage)); Villages.resize(numVillage); // For each village for(uint k = 0; k < numVillage; ++k) { // Village pointer const UFormElm *villageForm; if (elm->getArrayNode (&villageForm, k) && villageForm) { Villages[k].build(*villageForm); elm->getArrayNodeName(Villages[k].Name, k); } } } // load the weather functions // Build season descriptor static const char *seasonFuncName[] = { "SpringWeatherFunction", "SummerWeatherFunction", "AutumnWeatherFunction", "WinterWeatherFunction" }; // added - 1 because there is an invalid season nlctassert(sizeof(seasonFuncName) / sizeof(seasonFuncName[0]) == EGSPD::CSeason::Invalid ); // Load weather functions & sky sheets for(uint k = 0; k < EGSPD::CSeason::Invalid; ++k) { const NLGEORGES::UFormElm *elm; if (item.getNodeByName(&elm, seasonFuncName[k]) && elm) { WeatherFunction[k].build(*elm); } } }
void CSampleBankManager::init(NLGEORGES::UFormElm *mixerConfig) { if (mixerConfig == 0) return; NLGEORGES::UFormElm *virtualBanks; mixerConfig->getNodeByName(&virtualBanks, ".VirtualBanks"); if (virtualBanks == 0) return; uint size; virtualBanks->getArraySize(size); for (uint i=0; i<size; ++i) { NLGEORGES::UFormElm *virtualBank; virtualBanks->getArrayNode(&virtualBank, i); if (virtualBank != 0) { std::vector<TFilteredBank> vfb; std::string virtualName; virtualBank->getValueByName(virtualName, ".VirtualName"); NLGEORGES::UFormElm *realBanks; virtualBank->getNodeByName(&realBanks, ".FilteredBank"); if (realBanks != 0) { uint size2; realBanks->getArraySize(size2); for (uint j=0; j<size2; ++j) { TFilteredBank fb; std::string bankName; NLGEORGES::UFormElm *realBank; realBank->getArrayNode(&realBank, j); realBank->getValueByName(bankName, ".SampleBank"); fb.BankName = CStringMapper::map(bankName); realBank->getValueByName(fb.Filter, ".Filter"); vfb.push_back(fb); } } if (!vfb.empty()) { TStringId virtualNameId = CStringMapper::map(virtualName); m_VirtualBanks.insert(std::make_pair(virtualNameId, vfb)); // create the sample bank CSampleBank *sampleBank = new CSampleBank(virtualNameId, this); } } } }
//----------------------------------------------- bool CDirLightSetup::build(const NLGEORGES::UFormElm &item) { NLMISC::CRGBA amb, dif, spe; NLMISC::CVector dir; const NLGEORGES::UFormElm *pElt; // Light Direction if (item.getNodeByName (&pElt, ".Direction") && pElt) { if (!CGeorgesHelper::convert(dir, *pElt)) return false; } // Light Ambiant if (item.getNodeByName (&pElt, ".Ambiant") && pElt) { if (!CGeorgesHelper::convert(amb, *pElt)) return false; } // Light Diffuse if (item.getNodeByName (&pElt, ".Diffuse") && pElt) { if (!CGeorgesHelper::convert(dif, *pElt)) return false; } // Light Specular if (item.getNodeByName (&pElt, ".Specular") && pElt) { if (!CGeorgesHelper::convert(spe, *pElt)) return false; } Ambiant = amb; Diffuse = dif; Specular = spe; Direction = dir; return true; }
/// Load the sound parameters from georges' form void CContextSound::importForm(const std::string& filename, NLGEORGES::UFormElm& formRoot) { NLGEORGES::UFormElm *psoundType; std::string dfnName; // some basic checking. formRoot.getNodeByName(&psoundType, ".SoundType"); nlassert(psoundType != NULL); psoundType->getDfnName(dfnName); nlassert(dfnName == "context_sound.dfn"); // Call the base class CSound::importForm(filename, formRoot); // Read the pattern name formRoot.getValueByName(_PatternName, ".SoundType.PatternName"); }
// ******************************************************************************************* void CIDToStringArraySheet::build(const NLGEORGES::UFormElm &item) { const UFormElm *stringArray = NULL; if (item.getNodeByName(&stringArray, "Array") && stringArray) { std::string str; uint numStr; nlverify(stringArray->getArraySize(numStr)); Array.reserve(numStr); for(uint k = 0; k < numStr; ++k) { const UFormElm *strNode = NULL; if (stringArray->getArrayNode(&strNode, k) && strNode) { Array.push_back(CIDToString()); Array.back().build(*strNode); } } } }
/** * Load the sound parameters from georges' form */ void CSimpleSound::importForm(const std::string& filename, NLGEORGES::UFormElm& root) { NLGEORGES::UFormElm *psoundType; std::string dfnName; // some basic checking. root.getNodeByName(&psoundType, ".SoundType"); nlassert(psoundType != NULL); psoundType->getDfnName(dfnName); nlassert(dfnName == "simple_sound.dfn"); // Call the base class CSound::importForm(filename, root); // Name _Filename = CStringMapper::map(filename); // Buffername std::string bufferName; root.getValueByName(bufferName, ".SoundType.Filename"); bufferName = CFile::getFilenameWithoutExtension(bufferName); _Buffername = CStringMapper::map(bufferName); setBuffer(NULL); // contain % so it need a context to play if (bufferName.find ("%") != string::npos) { _NeedContext = true; } // MaxDistance root.getValueByName(_MaxDist, ".SoundType.MaxDistance"); // MinDistance root.getValueByName(_MinDist, ".SoundType.MinDistance"); // Alpha root.getValueByName(_Alpha, ".SoundType.Alpha"); }
void CStreamSound::importForm(const std::string &filename, NLGEORGES::UFormElm &root) { NLGEORGES::UFormElm *psoundType; std::string dfnName; // some basic checking. root.getNodeByName(&psoundType, ".SoundType"); nlassert(psoundType != NULL); psoundType->getDfnName(dfnName); nlassert(dfnName == "stream_sound.dfn"); // Call the base class CSound::importForm(filename, root); // MaxDistance root.getValueByName(_MaxDist, ".SoundType.MaxDistance"); // MinDistance root.getValueByName(_MinDist, ".SoundType.MinDistance"); // Alpha root.getValueByName(m_Alpha, ".SoundType.Alpha"); }
// *************************************************************************************************** void CFloraSheet::build(const NLGEORGES::UFormElm &item) { const UFormElm *plantArray = NULL; if (item.getNodeByName(&plantArray, "Plants") && plantArray) { uint numPlants; nlverify(plantArray->getArraySize(numPlants)); _Plants.reserve(numPlants); for(uint k = 0; k < numPlants; ++k) { const UFormElm *subNode = NULL; if (plantArray->getArrayNode(&subNode, k) && subNode) { CPlantInfo pi; pi.build(*subNode); pi.CumulatedWeight = _TotalWeight; _TotalWeight += pi.Weight; _Plants.push_back(pi); } } } item.getValueByName(MicroLifeThreshold, "MicroLifeThreshold"); }
//----------------------------------------------- // build : // Build the sheet from an external script. //----------------------------------------------- void CItemSheet::build(const NLGEORGES::UFormElm &item) { // Load the name. string Shape; if(!item.getValueByName(Shape, "3d.shape")) debug("key '3d.shape' not found."); IdShape = ClientSheetsStrings.add(Shape); // Load the name. string ShapeFemale; if(!item.getValueByName(ShapeFemale, "3d.shape_female")) debug("key '3d.shape_female' not found."); IdShapeFemale = ClientSheetsStrings.add(ShapeFemale); // Get the icon associated. string IconMain; if(!item.getValueByName (IconMain, "3d.icon")) debug("key '3d.icon' not found."); IconMain = strlwr (IconMain); IdIconMain = ClientSheetsStrings.add(IconMain); // Get the icon associated. string IconBack; if(!item.getValueByName (IconBack, "3d.icon background")) debug("key '3d.icon background' not found."); IconBack = strlwr (IconBack); IdIconBack = ClientSheetsStrings.add(IconBack); // Get the icon associated. string IconOver; if(!item.getValueByName (IconOver, "3d.icon overlay")) debug("key '3d.icon overlay' not found."); IconOver = strlwr (IconOver); IdIconOver = ClientSheetsStrings.add(IconOver); // Get the icon associated. string IconOver2; if(!item.getValueByName (IconOver2, "3d.icon overlay2")) debug("key '3d.icon overlay2' not found."); IconOver2 = strlwr (IconOver2); IdIconOver2 = ClientSheetsStrings.add(IconOver2); // Get Special modulate colors item.getValueByName (IconColor, "3d.IconColor" ); item.getValueByName (IconBackColor, "3d.IconBackColor"); item.getValueByName (IconOverColor, "3d.IconOverColor"); item.getValueByName (IconOver2Color, "3d.IconOver2Color"); // Get the icon text associated. string IconText; if(!item.getValueByName (IconText, "3d.text overlay")) debug("key '3d.text overlay' not found."); IconText = strlwr (IconText); IdIconText = ClientSheetsStrings.add(IconText); // See if this item can be hiden when equiped if(!item.getValueByName (NeverHideWhenEquiped, "3d.never hide when equiped")) debug("key '3d.never hide when equiped."); // Load the different slot in wicth the item can be equipped. const UFormElm *pElt = 0; // check uint32 is OK! nlassert( SLOTTYPE::NB_SLOT_TYPE <= 32 ); SlotBF= 0; if(item.getNodeByName(&pElt, "basics.EquipmentInfo.EquipmentSlots") && pElt) { // Get all slots. uint size; if(pElt->getArraySize(size)) { for(uint i = 0; i < size; ++i) { string slotName; if(pElt->getArrayValue(slotName, i)) { // Check name. if(slotName.empty()) debug(toString("The slot name %d is Empty.", i)); // Push the possible slots for the item in the list. SlotBF|= SINT64_CONSTANT(1)<< (SLOTTYPE::stringToSlotType(NLMISC::toUpper(slotName))); } } } else debug("The element 'basics.Equipment Slot' is not an array."); } else debug("Cannot create the element from the name 'basics.Equipment Slot'."); // Get the Item Family. string family; if(!item.getValueByName(family, "basics.family")) { debug("Key 'basics.family' not found."); Family = ITEMFAMILY::UNDEFINED; } else { Family = (ITEMFAMILY::EItemFamily) ITEMFAMILY::stringToItemFamily(NLMISC::toUpper( family) ); if(Family == ITEMFAMILY::UNDEFINED) debug("Item Family Undefined."); } // Get the Item Type. string itemtype; if(!item.getValueByName(itemtype, "basics.ItemType")) { debug("Key 'basics.ItemType' not found."); ItemType = ITEM_TYPE::UNDEFINED; } else { ItemType = (ITEM_TYPE::TItemType) ITEM_TYPE::stringToItemType(NLMISC::toUpper(itemtype) ); if (ItemType == ITEM_TYPE::UNDEFINED) debug("Item Type Undefined."); } // Get the DropOrSell property if(!item.getValueByName (DropOrSell, "basics.Drop or Sell")) debug("key 'basics.Drop or Sell' not found."); // Get the IsItemNoRent property if(!item.getValueByName (IsItemNoRent, "basics.No Rent")) debug("key 'basics.No Rent' not found."); // Get the stackable property if(!item.getValueByName (Stackable, "basics.stackable")) debug("key 'basics.stackable' not found."); // Get the Consumable property if(!item.getValueByName (IsConsumable, "basics.Consumable")) debug("key 'basics.Consumable' not found."); // Get the texture variante. if(!item.getValueByName(MapVariant, "3d.map_variant")) debug("Key '3d.map_variant' not found."); // Load the name. string AnimSet; if(!item.getValueByName(AnimSet, "3d.anim_set")) debug("key '3d.anim_set' not found."); // Force the CASE in UPPER to not be CASE SENSITIVE. else NLMISC::strlwr(AnimSet); IdAnimSet = ClientSheetsStrings.add(AnimSet); // Get the Trail Shape if(!item.getValueByName(Color, "3d.color")) debug("key '3d.color' not found."); // Get the Fx flag if(!item.getValueByName(HasFx, "3d.has_fx")) debug("key '3d.has_fx' not found."); // Get special Effect1 string Effect1; if(!item.getValueByName(Effect1, "Effects.Effect1")) debug("key 'Effects.Effect1' not found."); Effect1 = strlwr(Effect1); IdEffect1 = ClientSheetsStrings.add(Effect1); // Get special Effect2 string Effect2; if(!item.getValueByName(Effect2, "Effects.Effect2")) debug("key 'Effects.Effect2' not found."); Effect2 = strlwr(Effect2); IdEffect2 = ClientSheetsStrings.add(Effect2); // Get special Effect3 string Effect3; if(!item.getValueByName(Effect3, "Effects.Effect3")) debug("key 'Effects.Effect3' not found."); Effect3 = strlwr(Effect3); IdEffect3 = ClientSheetsStrings.add(Effect3); // Get special Effect4 string Effect4; if(!item.getValueByName(Effect4, "Effects.Effect4")) debug("key 'Effects.Effect4' not found."); Effect4 = strlwr(Effect4); IdEffect4 = ClientSheetsStrings.add(Effect4); // Get its bulk TRANSLATE_VAL( Bulk, "basics.Bulk" ); // Get its equip time TRANSLATE_VAL( EquipTime, "basics.Time to Equip In Ticks" ); // build fx part FX.build(item, "3d.fx."); // **** Build Help Infos string val; TRANSLATE_ENUM( RequiredCharac, CHARACTERISTICS::Unknown, CHARACTERISTICS::toCharacteristic, "basics.RequiredCharac"); TRANSLATE_VAL( RequiredCharacLevel, "basics.MinRequiredCharacLevel"); TRANSLATE_ENUM( RequiredSkill, SKILLS::unknown, SKILLS::toSkill, "basics.RequiredSkill"); TRANSLATE_VAL( RequiredSkillLevel, "basics.MinRequiredSkillLevel"); // item Origin TRANSLATE_ENUM ( ItemOrigin, ITEM_ORIGIN::UNKNOWN, ITEM_ORIGIN::stringToEnum, "basics.origin"); /// item craft plan TRANSLATE_VAL( val, "basics.CraftPlan" ); if (!val.empty()) CraftPlan = CSheetId(val); // Special according to Family; switch(Family) { // COSMETIC case ITEMFAMILY::COSMETIC : { string sheetName = Id.toString(); string::size_type pos = sheetName.find('.',0); if (pos == string::npos) nlwarning("<loadCosmetics> Can't load the VPValue from sheet name in sheet %s", Id.toString().c_str() ); else { sint i = (sint)pos - 1; for(; i >= 0; i-- ) { if ( !isdigit( sheetName[i] ) ) break; } if ( i >= -1 ) { string val = sheetName.substr( i + 1, pos - i - 1); NLMISC::fromString( val, Cosmetic.VPValue ); } } if ( sheetName.find( "hof" ) != string::npos ) Cosmetic.Gender = GSGENDER::female; else Cosmetic.Gender = GSGENDER::male; } break; // ARMOR case ITEMFAMILY::ARMOR : { // ArmorType TRANSLATE_ENUM ( Armor.ArmorType, ARMORTYPE::UNKNOWN, ARMORTYPE::toArmorType, "armor.Armor category" ); } break; // MELEE_WEAPON case ITEMFAMILY::MELEE_WEAPON : { // WeaponType TRANSLATE_ENUM ( MeleeWeapon.WeaponType, WEAPONTYPE::UNKNOWN, WEAPONTYPE::stringToWeaponType, "melee weapon.category" ); // Skill TRANSLATE_ENUM ( MeleeWeapon.Skill, SKILLS::unknown, SKILLS::toSkill, "melee weapon.skill" ); // DamageType TRANSLATE_ENUM ( MeleeWeapon.DamageType, DMGTYPE::UNDEFINED, DMGTYPE::stringToDamageType, "melee weapon.damage type" ); // DamageType TRANSLATE_VAL ( MeleeWeapon.MeleeRange, "melee weapon.melee range" ); } break; // RANGE_WEAPON case ITEMFAMILY::RANGE_WEAPON : { // WeaponType TRANSLATE_ENUM ( RangeWeapon.WeaponType, WEAPONTYPE::UNKNOWN, WEAPONTYPE::stringToWeaponType, "range weapon.category" ); // Range weapon type TRANSLATE_ENUM ( RangeWeapon.RangeWeaponType, RANGE_WEAPON_TYPE::Generic, RANGE_WEAPON_TYPE::stringToRangeWeaponType, "range weapon.RangeWeaponType" ); // Skill TRANSLATE_ENUM ( RangeWeapon.Skill, SKILLS::unknown, SKILLS::toSkill, "range weapon.skill" ); } break; // AMMO case ITEMFAMILY::AMMO : { // Skill TRANSLATE_ENUM ( Ammo.Skill, SKILLS::unknown, SKILLS::toSkill, "ammo.weapon type" ); // DamageType TRANSLATE_ENUM ( Ammo.DamageType, DMGTYPE::UNDEFINED, DMGTYPE::stringToDamageType, "ammo.damage type" ); // Magazine TRANSLATE_VAL( Ammo.Magazine, "ammo.magazine" ); } break; // RAW_MATERIAL case ITEMFAMILY::RAW_MATERIAL : { // Ecosystem TRANSLATE_ENUM( Mp.Ecosystem, ECOSYSTEM::unknown, ECOSYSTEM::stringToEcosystem, "mp.Ecosystem" ); // MpCategory TRANSLATE_ENUM( Mp.MpCategory, MP_CATEGORY::Undefined, MP_CATEGORY::stringToMPCategory, "mp.Category" ); // Skill TRANSLATE_ENUM( Mp.HarvestSkill, SKILLS::unknown, SKILLS::toSkill, "mp.HarvestSkill" ); // MP Family TRANSLATE_VAL( Mp.Family, "mp.Family" ); // Faber Item Part uint i; char keyTmp[256]; // ensure that if you modify RM_FABER_TYPE, you have to rebuild the item sheets. nlctassert(RM_FABER_TYPE::NUM_FABER_TYPE == 26); // ensure that the bitfields are enough (nb: unknown can be stored) nlctassert(ITEM_ORIGIN::NUM_ITEM_ORIGIN < 256); // ensure that the bitfield for item part buildable for this MP is possible nlctassert(RM_FABER_TYPE::NUM_FABER_TYPE <= 32); // reset Mp.ItemPartBF= 0; MpItemParts.clear(); // check if ok for each for(i=0;i<RM_FABER_TYPE::NUM_FABER_TYPE ;i++) { uint32 durability= 0; string sheetEntry= RM_FABER_TYPE::faberTypeToSheetEntry((RM_FABER_TYPE::TRMFType)i); // read the associated durablity of the MP faberType sprintf(keyTmp, "mp.MpParam.%s.Durability", sheetEntry.c_str()); TRANSLATE_VAL(durability, keyTmp); // If not null, ok this MP is associated to this faberType if(durability) { Mp.ItemPartBF |= SINT64_CONSTANT(1)<<i; MpItemParts.push_back(CMpItemPart()); CMpItemPart &itemPart= MpItemParts.back(); // read origin filter sprintf(keyTmp, "mp.MpParam.%s.CraftCivSpec", sheetEntry.c_str()); TRANSLATE_ENUM( itemPart.OriginFilter, ITEM_ORIGIN::UNKNOWN, ITEM_ORIGIN::stringToEnum, keyTmp); // read each stat for(uint j=0;j<RM_FABER_STAT_TYPE::NumRMStatType;j++) { sprintf(keyTmp, "mp.MpParam.%s.%s", sheetEntry.c_str(), RM_FABER_STAT_TYPE::toString((RM_FABER_STAT_TYPE::TRMStatType)j).c_str()); TRANSLATE_VAL( itemPart.Stats[j], keyTmp); } } } // UsedAsCraftRequirement TRANSLATE_VAL( Mp.UsedAsCraftRequirement, "mp.UsedAsCraftRequirement" ); // MpColor TRANSLATE_VAL( Mp.MpColor, "mp.MpColor" ); // Mp Stat Energy TRANSLATE_VAL( Mp.StatEnergy, "mp.StatEnergy"); } break; // SHIELD case ITEMFAMILY::SHIELD : { // ShieldType TRANSLATE_ENUM( Shield.ShieldType, SHIELDTYPE::NONE, SHIELDTYPE::stringToShieldType, "shield.Category" ); } break; // TOOL: different for any tool case ITEMFAMILY::CRAFTING_TOOL : { // CraftingToolType TRANSLATE_ENUM( Tool.CraftingToolType, TOOL_TYPE::Unknown, TOOL_TYPE::toToolType, "crafting tool.type"); } break; case ITEMFAMILY::HARVEST_TOOL : { // Skill TRANSLATE_ENUM( Tool.Skill, SKILLS::unknown, SKILLS::toSkill, "harvest tool.skill" ); } break; case ITEMFAMILY::TAMING_TOOL : { // Skill TRANSLATE_ENUM( Tool.Skill, SKILLS::unknown, SKILLS::toSkill, "taming tool.skill" ); // CommandRange TRANSLATE_VAL( Tool.CommandRange, "taming tool.command range" ); // MaxDonkey TRANSLATE_VAL( Tool.MaxDonkey, "taming tool.max donkey" ); } break; case ITEMFAMILY::GUILD_OPTION : { // Cost in money of the tool TRANSLATE_VAL( GuildOption.MoneyCost, "guild option.Money Cost" ); // Cost in guild XP TRANSLATE_VAL( GuildOption.XPCost, "guild option.Guild XP Cost" ); } break; case ITEMFAMILY::PET_ANIMAL_TICKET : { // Cost in money of the tool TRANSLATE_VAL( Pet.Slot, "pet.Pet Slot" ); } break; case ITEMFAMILY::TELEPORT: { // Type of teleport TRANSLATE_ENUM( Teleport.Type, TELEPORT_TYPES::NONE, TELEPORT_TYPES::getTpTypeFromString, "teleport.Type" ); } break; case ITEMFAMILY::SCROLL: { // Scroll texture TRANSLATE_VAL( Scroll.Texture, "Scroll.Texture"); } break; case ITEMFAMILY::CONSUMABLE: { TRANSLATE_VAL( Consumable.ConsumptionTime, "Consumable.ConsumptionTime"); TRANSLATE_VAL( Consumable.OverdoseTimer, "Consumable.OverdoseTimer"); Consumable.Properties.clear(); for(uint i=0;i<4;i++) { string val; item.getValueByName(val, toString("Consumable.Property %d", i).c_str() ); if(!val.empty() && val!="NULL") { Consumable.Properties.push_back(val); } } } break; default: break; }; }// build //
/** Load additionnal ig from a continent (ryzom specific) * \param parameter a config file that contains the name of the continent containing the zones we are processing * \param zone2bbox This will be filled with the name of a zone and the bbox of the village it contains * \param a map of shape * \param a vector that will be filled with a zone name and the bbox of the village it contains */ static void computeIGBBoxFromContinent(NLMISC::CConfigFile ¶meter, TShapeMap &shapeMap, TString2LightingBBox &zone2BBox ) { try { CConfigFile::CVar &continent_name_var = parameter.getVar ("continent_name"); CConfigFile::CVar &level_design_directory = parameter.getVar ("level_design_directory"); CConfigFile::CVar &level_design_world_directory = parameter.getVar ("level_design_world_directory"); CConfigFile::CVar &level_design_dfn_directory = parameter.getVar ("level_design_dfn_directory"); CPath::addSearchPath(level_design_dfn_directory.asString(), true, false); CPath::addSearchPath(level_design_world_directory.asString(), true, false); std::string continentName = continent_name_var.asString(); if (CFile::getExtension(continentName).empty()) continentName += ".continent"; // Load the form NLGEORGES::UFormLoader *loader = NLGEORGES::UFormLoader::createLoader(); // std::string pathName = level_design_world_directory.asString() + "/" + continentName; if (pathName.empty()) { nlwarning("Can't find continent form : %s", continentName.c_str()); return; } NLGEORGES::UForm *villageForm; villageForm = loader->loadForm(pathName.c_str()); if(villageForm != NULL) { NLGEORGES::UFormElm &rootItem = villageForm->getRootNode(); // try to get the village list // Load the village list NLGEORGES::UFormElm *villagesItem; if(!(rootItem.getNodeByName (&villagesItem, "Villages") && villagesItem)) { nlwarning("No villages where found in %s", continentName.c_str()); return; } // Get number of village uint numVillage; nlverify (villagesItem->getArraySize (numVillage)); // For each village for(uint k = 0; k < numVillage; ++k) { NLGEORGES::UFormElm *currVillage; if (!(villagesItem->getArrayNode (&currVillage, k) && currVillage)) { nlwarning("Couldn't get village %d in continent %s", continentName.c_str(), k); continue; } // check that this village is in the dependency zones NLGEORGES::UFormElm *zoneNameItem; if (!currVillage->getNodeByName (&zoneNameItem, "Zone") && zoneNameItem) { nlwarning("Couldn't get zone item of village %d in continent %s", continentName.c_str(), k); continue; } std::string zoneName; if (!zoneNameItem->getValue(zoneName)) { nlwarning("Couldn't get zone name of village %d in continent %s", continentName.c_str(), k); continue; } zoneName = NLMISC::toLower(CFile::getFilenameWithoutExtension(zoneName)); CLightingBBox result; // ok, it is in the dependant zones computeBBoxFromVillage(currVillage, continentName, k, shapeMap, result); if (!result.OccludingBox.IsVoid || result.ReceivingBox.IsVoid) { zone2BBox[zoneName] = result; } } } else { nlwarning("Can't load continent form : %s", continentName.c_str()); } } catch (NLMISC::EUnknownVar &e) { nlinfo(e.what()); } }
//========================================================================= void CContinentParameters::build(const NLGEORGES::UFormElm &item) { // Name. item.getValueByName (Name, "Name"); // WorldMap item.getValueByName (WorldMap, "WorldMap"); //Zone min/max item.getValueByName (ZoneMin, "ZoneMin"); item.getValueByName (ZoneMax, "ZoneMax"); // Load Light Landscape Day. const UFormElm *elm; if (item.getNodeByName (&elm, "LightLandscapeDay") && elm) LandscapeLightDay.build(*elm); // Load Light Landscape Night. if (item.getNodeByName (&elm, "LightLandscapeNight") && elm) LandscapeLightNight.build(*elm); // Load Light Landscape Dusk. if (item.getNodeByName (&elm, "LightLandscapeDusk") && elm) { if (!LandscapeLightDusk.build(*elm)) LandscapeLightDusk.blend(LandscapeLightDay, LandscapeLightNight, 0.5f); } else LandscapeLightDusk.blend(LandscapeLightDay, LandscapeLightNight, 0.5f); // Load Landscape PointLightMaterial if (item.getNodeByName (&elm, "LandscapePointLightMaterial") && elm) CGeorgesHelper::convert (LandscapePointLightMaterial, *elm); else LandscapePointLightMaterial= CRGBA::White; // Load Light Entity Day. if (item.getNodeByName (&elm, "LightEntityDay") && elm) EntityLightDay.build(*elm); // Load Light Entity Night. if (item.getNodeByName (&elm, "LightEntityNight") && elm) EntityLightNight.build(*elm); // Load Light Entity Dusk if (item.getNodeByName (&elm, "LightEntityDusk") && elm) { if (!EntityLightDusk.build(*elm)) EntityLightDusk.blend(EntityLightDay, EntityLightNight, 0.5f); } else EntityLightDusk.blend(EntityLightDay, EntityLightNight, 0.5f); // Load Light Root Day. if (item.getNodeByName (&elm, "LightRootDay") && elm) RootLightDay.build(*elm); // Load Light Root Night. if (item.getNodeByName (&elm, "LightRootNight") && elm) RootLightNight.build(*elm); // Load Light Root Dusk if (item.getNodeByName (&elm, "LightRootDusk") && elm) { if (!RootLightDusk.build(*elm)) RootLightDusk.blend(RootLightDay, RootLightNight, 0.5f); } else RootLightDusk.blend(RootLightDay, RootLightNight, 0.5f); // Load Entity sun contribution power. item.getValueByName (EntitySunContributionPower, "EntitySunPower"); // Load Entity sun contribution max threshold. item.getValueByName (EntitySunContributionMaxThreshold, "EntitySunMaxThreshold"); // Load PACS RBank. item.getValueByName (PacsRBank, "PacsRBank"); // Load PACS RBank. item.getValueByName (PacsGR, "PacsGR"); // Load IG list filename. item.getValueByName (LandscapeIG, "LandscapeIG"); // Load Sky day filename. item.getValueByName (SkyDay, "SkyDay"); // Load Sky night filename. item.getValueByName (SkyNight, "SkyNight"); // Load Sky fog part filename. item.getValueByName (SkyFogPartName, "SkyFogPart"); // Load Sky ig filename. item.getValueByName (BackgroundIGName, "SkyIg"); // Load IG for canopy for each season for (uint season = 0; season < EGSPD::CSeason::Invalid; ++season) { item.getValueByName(CanopyIGfileName[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season) + "CanopyIG").c_str()); } // Load the form string filename; if (item.getValueByName (filename, "Ecosystem")) { UFormLoader *loader = UFormLoader::createLoader(); if (loader) { // Load the form CSmartPtr<UForm> form = loader->loadForm (filename.c_str ()); // Form loaded ? if (form) { // Root node elm = &form->getRootNode (); // MicroVeget. elm->getValueByName (MicroVeget, "MicroVeget"); // Small bank. elm->getValueByName (SmallBank, "SmallBank"); // Far bank. elm->getValueByName (FarBank, "FarBank"); // Coarse mesh texture. elm->getValueByName (CoarseMeshMap, "CoarseMeshMap"); } else { nlwarning("CContinent::build : Can't load form %s.", filename.c_str()); } UFormLoader::releaseLoader(loader); } } // Load all "Zone Constructible". if(item.getNodeByName(&elm, "ZCs") && elm) { // Get number of ZC uint nbZC; if(elm->getArraySize(nbZC)) { // For each village for(uint i = 0; i < nbZC; ++i) { // Village pointer const UFormElm *zc; if(elm->getArrayNode(&zc, i) && zc) { // Get the zone associated. CZC zone; zone.EnableRuins= true; if(!zc->getValueByName(zone.Name, "Zone")) nlwarning("CContinent::build : key 'Zone' not found."); if(!zc->getValueByName(zone.ForceLoadDist, "ForceLoadDist")) nlwarning("CContinent::build : key 'ForceLoadDist' not found."); if(!zc->getValueByName(zone.LoadDist, "LoadDist")) nlwarning("CContinent::build : key 'LoadDist' not found."); if(!zc->getValueByName(zone.UnloadDist, "UnloadDist")) nlwarning("CContinent::build : key 'UnloadDist' not found."); if(!zc->getValueByName(zone.EnableRuins, "EnableRuins")) nlwarning("CContinent::build : key 'EnableRuins' not found."); ZCList.push_back(zone); } } } else nlwarning("CContinent::build : it seems 'ZCs' is not an array."); } // build fog map descriptor buildFogMapBuild(item); // Load Sky ig filename. item.getValueByName (Indoor, "Indoor"); // Load the landmark list /* if(item.getNodeByName (&elm, "LandMarks") && elm) { // Get number of village uint numLandMarks; nlverify (elm->getArraySize (numLandMarks)); LandMarks.resize(numLandMarks); // For each village for(uint k = 0; k < numLandMarks; ++k) { // Village pointer const UFormElm *landMarkForm; if (elm->getArrayNode (&landMarkForm, k) && landMarkForm) { LandMarks[k].build(*landMarkForm); } } }*/ // LocalizedName item.getValueByName (LocalizedName, "LocalizedName"); // Micro-life primitives if(item.getNodeByName(&elm, "MicroLifePrimitives") && elm) { // Get number of prims uint numPrims; if(elm->getArraySize(numPrims)) { // For each prims for(uint i = 0; i < numPrims; ++i) { std::string primFilename; if (elm->getArrayValue(primFilename, i)) { MicroLifeZones.push_back(primFilename); } } } else nlwarning("CContinent::build : it seems 'ZCs' is not an array."); } // Read Season related parameters for (uint season = 0; season < EGSPD::CSeason::Invalid; ++season) { item.getValueByName(TileColorMono[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season) + "TileColorMono").c_str()); item.getValueByName(TileColorFactor[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season ) + "TileColorFactor").c_str()); item.getValueByName(StaticLightingFactor[season], (EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season ) + "StaticLightingFactor").c_str()); item.getValueByName(SkySheet[season], ("SkySheet" + EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season )).c_str()); // A continent may want to force some season instead another. read it ForceDisplayedSeason[season]= (EGSPD::CSeason::TSeason)season; string strSeason; item.getValueByName(strSeason, ("DisplayedSeasonFor" + EGSPD::CSeason::toString( (EGSPD::CSeason::TSeason)season)).c_str()); EGSPD::CSeason::TSeason readSeason= ForceDisplayedSeason[season]= EGSPD::CSeason::fromString(strSeason); if(readSeason<EGSPD::CSeason::Invalid) ForceDisplayedSeason[season]= readSeason; } }
//********************************************************************************************** void CVillageGrid::addVillagesFromContinent(const std::string &continentSheetName) { // Load the form NLGEORGES::UFormLoader *loader = NLGEORGES::UFormLoader::createLoader(); // std::string path = CPath::lookup(continentSheetName, false, false); if (path.empty()) { nlwarning("Path not found for %s.", continentSheetName.c_str()); return; } NLGEORGES::UForm *villageForm; villageForm = loader->loadForm(path.c_str()); if(villageForm != NULL) { NLGEORGES::UFormElm &rootItem = villageForm->getRootNode(); // try to get the village list // Load the village list NLGEORGES::UFormElm *villagesItem; if(!(rootItem.getNodeByName (&villagesItem, "Villages") && villagesItem)) { nlwarning("No villages where found in %s", continentSheetName.c_str()); return; } // Get number of village uint numVillage; nlverify (villagesItem->getArraySize (numVillage)); // For each village for(uint k = 0; k < numVillage; ++k) { NLGEORGES::UFormElm *currVillage; if (!(villagesItem->getArrayNode (&currVillage, k) && currVillage)) { nlwarning("Couldn't get village %d in continent %s", continentSheetName.c_str(), k); continue; } // check that this village is in the dependency zones NLGEORGES::UFormElm *zoneNameItem; if (!currVillage->getNodeByName (&zoneNameItem, "Zone") && zoneNameItem) { nlwarning("Couldn't get zone item of village %d in continent %s", continentSheetName.c_str(), k); continue; } std::string zoneName; if (!zoneNameItem->getValue(zoneName)) { nlwarning("Couldn't get zone name of village %d in continent %s", continentSheetName.c_str(), k); continue; } sint zoneX, zoneY; if (!getZonePos(zoneName, zoneX, zoneY)) { nlwarning("Zone name of village %d in continent %s is invalid", continentSheetName.c_str(), k); continue; } sint villageMinX, villageMinY; sint villageMaxX, villageMaxY; // retrieve width & height of covered region uint32 regionWidth; uint32 regionHeight; float centerX, centerY; if (!currVillage->getValueByName(regionWidth, "Width") || !currVillage->getValueByName(regionHeight, "Height") || !currVillage->getValueByName(centerX, "CenterX") || !currVillage->getValueByName(centerY, "CenterY")) { nlwarning("Can't retrieve region covered by village %d in continent %s", continentSheetName.c_str(), k); continue; } // villageMinX = villageMaxX = zoneX; villageMinY = villageMaxY = zoneY; // extends with bbox from center to min corner if leveldesigner forgot to enter good width & height villageMaxX = std::max(villageMaxX, (sint) ((zoneX * 160.f + 2.f * centerX) / 160.f)); villageMaxY = std::max(villageMaxY, (sint) ((zoneY * 160.f + 2.f * centerY) / 160.f)); // villageMinX -= _ZoneMinX; villageMaxX -= _ZoneMinX; villageMinY -= _ZoneMinY; villageMaxY -= _ZoneMinY; // CVillage village; if (loadVillageSheet(currVillage, continentSheetName, k, village)) { // village.FileModificationDate = std::max(village.FileModificationDate, CFile::getFileModificationDate(path)); // Villages.push_back(CVillage()); Villages.back().swap(village); // for (sint y = villageMinY; y <= (sint) villageMaxY; ++y) { if (y < 0) continue; if (y >= (sint) VillageGrid.getHeight()) continue; for (sint x = villageMinX; x <= (sint) villageMaxX; ++x) { if (x < 0) continue; if (x >= (sint) VillageGrid.getWidth()) continue; VillageGrid(x, y).push_back(Villages.size() - 1); } } } } } else { nlwarning("Can't load continent form : %s", continentSheetName.c_str()); } }
//----------------------------------------------- // build : // Build the sheet from an external script. //----------------------------------------------- void CCharacterSheet::build(const NLGEORGES::UFormElm &item) { // First Name // string FirstName; // if(!item.getValueByName(FirstName, "Basics.First Name")) // debug("Key 'Basics.First Name' not found."); // IdFirstName = ClientSheetsStrings.add(FirstName); // // Character Name // string LastName; // if(!item.getValueByName(LastName, "Basics.CharacterName")) // debug("Key 'Basics.CharacterName' not found."); // IdLastName = ClientSheetsStrings.add(LastName); // Fame Name string FameName; if(!item.getValueByName(FameName, "Basics.Fame")) debug("Key 'Basics.Fame' not found."); IdFame = ClientSheetsStrings.add(FameName); // Character Race string raceStr; if(!item.getValueByName(raceStr, "Basics.Race")) debug("Key 'Basics.Race' not found."); else if (!raceStr.empty()) { Race = EGSPD::CPeople::fromString(raceStr); if (EGSPD::CPeople::toString(Race) != raceStr) { debug(toString("In sheet '%s': invalid race '%s', race is set to unknow", Id.toString().c_str(), raceStr.c_str())); } } else Race = EGSPD::CPeople::Unknown; // Player Gender. if(!item.getValueByName(Gender, "Basics.Gender")) debug("Key 'Gender' not found."); // Load the skel. string SkelFilename; if(!item.getValueByName(SkelFilename, "3d data.Skel")) debug("Key '3d data.Skel' not found."); IdSkelFilename = ClientSheetsStrings.add(SkelFilename); // BODY readEquipment(item, "Basics.Equipment.Body", Body); // LEGS readEquipment(item, "Basics.Equipment.Legs", Legs); // ARMS readEquipment(item, "Basics.Equipment.Arms", Arms); // HANDS readEquipment(item, "Basics.Equipment.Hands", Hands); // FEET readEquipment(item, "Basics.Equipment.Feet", Feet); // HEAD readEquipment(item, "Basics.Equipment.Head", Head); // FACE readEquipment(item, "Basics.Equipment.Face", Face); // IN RIGHT HAND readEquipment(item, "Basics.Equipment.HandR", ObjectInRightHand); // IN LEFT HAND readEquipment(item, "Basics.Equipment.HandL", ObjectInLeftHand); // Get the animation set Base Name. string AnimSetBaseName; if(item.getValueByName(AnimSetBaseName, "3d data.AnimSetBaseName")) { if(AnimSetBaseName.empty()) debug("AnimSetBaseName is Empty."); else NLMISC::strlwr(AnimSetBaseName); // Force the CASE in UPPER to not be CASE SENSITIVE. } else debug("Key '3d data.AnimSetBaseName' not found."); IdAnimSetBaseName = ClientSheetsStrings.add(AnimSetBaseName); // AUTOMATON TYPE string Automaton; if(item.getValueByName(Automaton, "3d data.Automaton")) { // Check there is an automaton if(Automaton.empty()) debug("Automaton is Empty."); // Lower Case else NLMISC::strlwr(Automaton); } // Key not Found else debug("Key '3d data.Automaton' not found."); IdAutomaton = ClientSheetsStrings.add(Automaton); // Display OSD if(!item.getValueByName(DisplayOSD, "3d data.DisplayOSD")) { debug("Key '3d data.DisplayOSD' not found -> set 'true'."); DisplayOSD = true; } // New Bot Object flags TRANSLATE_VAL(DisplayInRadar, "3d data.DisplayInRadar"); TRANSLATE_VAL(DisplayOSDName,"3d data.DisplayName"); TRANSLATE_VAL(DisplayOSDBars,"3d data.DisplayBars"); TRANSLATE_VAL(DisplayOSDForceOver, "3d data.DisplayAlwaysNameOver"); TRANSLATE_VAL(Traversable, "Collision.NotTraversable"); // invert Traversable= !Traversable; // CREATURE PROPERTIES (Possible Actions) // Is the character selectable ? if(!item.getValueByName(Selectable, "Properties.Selectable")) { debug("Key 'Properties.Selectable' not found -> set 'false'."); Selectable = false; } // Is the character Talkable ? if(!item.getValueByName(Talkable, "Properties.Talkable")) { debug("Key 'Properties.Talkable' not found -> set 'false'."); Talkable = false; } // Is the character Attackable ? if(!item.getValueByName(Attackable, "Properties.Attackable")) { debug("Key 'Properties.Attackable' not found -> set 'false'."); Attackable = false; } // Is the character Givable ? if(!item.getValueByName(Givable, "Properties.Givable")) { debug("Key 'Properties.Givable' not found -> set 'false'."); Givable = false; } // Is the character Mountable ? if(!item.getValueByName(Mountable, "Properties.Mountable")) { debug("Key 'Properties.Mountable' not found -> set 'false'."); Mountable = false; } // Is the character allowed to turn ? if(!item.getValueByName(Turn, "Properties.Turn")) { debug("Key 'Properties.Turn' not found -> set 'true'."); Turn = true; } // Is the character selectable by pressing space (default) ? if(!item.getValueByName(SelectableBySpace, "Properties.SelectableBySpace")) { debug("Key 'Properties.SelectableBySpace' not found -> set 'true'."); SelectableBySpace = true; } //Get the harvest/loot state string harvestLootStr; if( !item.getValueByName(harvestLootStr, "Properties.LootHarvestState") ) debug("Key 'roperties.LootHarvestState' not found."); else HLState = LHSTATE::stringToLHState(harvestLootStr); // Get the Hair Color. if(!item.getValueByName(HairColor, "3d data.HairColor")) debug("Key '3d data.HairColor' not found."); // Get the Skin Texture. if(!item.getValueByName(Skin, "3d data.Skin")) debug("Key '3d data.Skin' not found."); // Get the Eyes Color. if(!item.getValueByName(EyesColor, "3d data.EyesColor")) debug("Key '3d data.EyesColor' not found."); // Load Lod character name string LodCharacterName; if(!item.getValueByName(LodCharacterName, "3d data.LodCharacterName")) debug("Key '3d data.LodCharacterName' not found."); IdLodCharacterName = ClientSheetsStrings.add(LodCharacterName); // Load Lod character apparition distance if(!item.getValueByName(LodCharacterDistance, "3d data.LodCharacterDistance")) debug("Key '3d data.LodCharacterDistance' not found."); // value to scale the "pos" channel of the animation of the player. if(!item.getValueByName(CharacterScalePos, "3d data.CharacterScalePos")) debug("Key '3d data.CharacterScalePos' not found."); // value to scale the "pos" channel of the animation of the player. if(!item.getValueByName(Scale, "3d data.Scale")) debug("Key '3d data.Scale' not found."); else { if(Scale <= 0.0f) { nlwarning("CCharacterSheet:build: Scale(%f) <= 0.0 so fix scale to 1.0", Scale); Scale = 1.0f; } } // Load name positions on Z axis if(!item.getValueByName(NamePosZLow, "3d data.NamePosZLow")) { NamePosZLow = 0.f; debug("Key '3d data.NamePosZLow' not found."); } if(!item.getValueByName(NamePosZNormal, "3d data.NamePosZNormal")) { NamePosZNormal = 0.f; debug("Key '3d data.NamePosZNormal' not found."); } if(!item.getValueByName(NamePosZHigh, "3d data.NamePosZHigh")) { NamePosZHigh = 0.f; debug("Key '3d data.NamePosZHigh' not found."); } // value to change sound familly if(!item.getValueByName(SoundFamily, "3d data.SoundFamily")) debug("Key '3d data.SoundFamily' not found."); // value to change sound variation if(!item.getValueByName(SoundVariation, "3d data.SoundVariation")) debug("Key '3d data.SoundVariation' not found."); // Get the dist fromm Bip to Mid float tmpBip01ToMid; if(!item.getValueByName(tmpBip01ToMid, "Collision.Dist Bip01 to mid")) { tmpBip01ToMid = 0.f; debug("Key 'Collision.Dist Bip01 to mid' not found."); } // Get the distance from the bip01 to the front. if(!item.getValueByName(DistToFront, "Collision.Dist Bip01 to front")) { DistToFront = 1.f; debug("Key 'Collision.Dist Bip01 to front' not found."); } // Get the distance from the bip01 to the front. if(!item.getValueByName(DistToBack, "Collision.Dist Bip01 to back")) { DistToBack = 1.f; debug("Key 'Collision.Dist Bip01 to back' not found."); } // Get the creature Width. if(!item.getValueByName(ColWidth, "Collision.Width")) { ColWidth = 1.f; debug("Key 'Collision.Width' not found."); } DistToSide = ColWidth; DistToFront = DistToFront-tmpBip01ToMid; DistToBack = tmpBip01ToMid-DistToBack; DistToSide = DistToSide/2.f; // Get the creature collision Radius. if(!item.getValueByName(ColRadius, "Collision.CollisionRadius")) { ColRadius = 0.5f; debug("Key 'Collision.CollisionRadius' not found."); } // Get the creature collision Height. if(!item.getValueByName(ColHeight, "Collision.Height")) { ColHeight = 2.f; debug("Key 'Collision.Height' not found."); } // Get the creature collision Length. if(!item.getValueByName(ColLength, "Collision.Length")) { ColLength = 1.f; debug("Key 'Collision.Length' not found."); } // CLIP if(!item.getValueByName(ClipRadius, "Collision.ClipRadius")) { ClipRadius = 0.f; debug("Key 'Collision.ClipRadius' not found."); } if(!item.getValueByName(ClipHeight, "Collision.ClipHeight")) { ClipHeight = 0.f; debug("Key 'Collision.ClipHeight' not found."); } // SPEED // // Get the creature Max Speed (Run). if(!item.getValueByName(MaxSpeed, "Basics.MovementSpeeds.RunSpeed")) { MaxSpeed = 10.f; debug("Key 'Basics.MovementSpeeds.RunSpeed' not found."); } const UFormElm *elm = NULL; // Get all alternative Clothes. static const char alternativeClothesKey[] = "Basics.Alternative Clothes"; if(item.getNodeByName(&elm, alternativeClothesKey) && elm) { // Check array. if(elm->isArray()) { // Get Array Size uint altClothesArraySize; if(elm->getArraySize(altClothesArraySize)) { // Get values. string altClothes; for(uint i=0; i<altClothesArraySize; ++i) { if(elm->getArrayValue(altClothes, i)) { if(!altClothes.empty()) { TSStringId IdAltClothes = ClientSheetsStrings.add(altClothes); IdAlternativeClothes.push_back(IdAltClothes); } else debug(toString("'%s' field empty for the index '%d'.", alternativeClothesKey, i)); } else debug(toString("'%s' cannot get the array value for the index '%d'.", alternativeClothesKey, i)); } } else debug(toString("'%s' cannot get the array size.", alternativeClothesKey)); } else debug(toString("'%s' is not an array.", alternativeClothesKey)); } else debug(toString("'%s' key not found.", alternativeClothesKey)); // Hair item list static const char hairItemList[] = "3d data.HairItem"; if(item.getNodeByName(&elm, hairItemList) && elm) { // Check array. if(elm->isArray()) { // Get Array Size uint hairItemArraySize; if(elm->getArraySize(hairItemArraySize)) { if(hairItemArraySize > 0) { // Adjust the array size. HairItemList.resize(hairItemArraySize); // Get values. for(uint i=0; i<hairItemArraySize; ++i) { string arrayNodeName; if(elm->getArrayNodeName(arrayNodeName, i)) readEquipment(item, string(hairItemList)+"["+toString(i)+"]", HairItemList[i]); } } } else debug(toString("'%s' cannot get the array size.", hairItemList)); } else debug(toString("'%s' is not an array.", hairItemList)); } else debug(toString("'%s' key not found.", hairItemList)); // ground fxs static const char groundFXList[] = "3d data.GroundFX"; if(item.getNodeByName(&elm, groundFXList) && elm) { // Check array. if(elm->isArray()) { // Get Array Size uint groundFXArraySize; if(elm->getArraySize(groundFXArraySize)) { if(groundFXArraySize > 0) { // Adjust the array size. GroundFX.reserve(groundFXArraySize); // Get values. for(uint i=0; i< groundFXArraySize; ++i) { const UFormElm *node; if (elm->getArrayNode(&node, i) && node != NULL) { CGroundFXSheet gfs; if (!gfs.build(*node)) { nlwarning("Error while building node %d", (int) i); } else { uint k; for(k = 0; k < GroundFX.size(); ++k) { if (GroundFX[k].GroundID == gfs.GroundID) { debug("Duplicated material"); GroundFX[k] = gfs; break; } } if (k == GroundFX.size()) { GroundFX.push_back(gfs); } } } } } } else debug(toString("'%s' cannot get the array size.", groundFXList)); } else debug(toString("'%s' is not an array.", groundFXList)); } else debug(toString("'%s' key not found.", groundFXList)); // sort fxs by ground type std::sort(GroundFX.begin(), GroundFX.end()); // Load Ground FX string staticFx; if(!item.getValueByName(staticFx, "3d data.FX")) debug("Key '3d data.FX' not found."); IdStaticFX = ClientSheetsStrings.add(staticFx); BodyToBone.build(item, "Localisation."); // Attack lists for(uint k = 0; k < NumAttackLists; ++k) { std::string attackListName; if(item.getValueByName(attackListName, toString("attack_list%d", (int) k).c_str()) && !attackListName.empty()) { AttackLists.push_back(ClientSheetsStrings.add(attackListName)); } } if(!item.getValueByName(RegionForce, "Basics.RegionForce")) { RegionForce = 0; debug("Key 'Basics.RegionForce' not found."); } if(!item.getValueByName(ForceLevel, "Basics.ForceLevel")) { ForceLevel = 0; debug("Key 'Basics.Regio Force' not found."); } if(!item.getValueByName(Level, "Basics.XPLevel")) { Level = 0; debug("Key 'Basics.XPLevel' not found."); } // offset for projectiles const UFormElm *pElt; nlverify (item.getNodeByName (&pElt, "3d data.ProjectileCastRay")); uint arraySize; if (pElt != NULL) { nlverify (pElt->getArraySize (arraySize)); ProjectileCastRay.reserve(arraySize); for (uint32 i = 0; i < arraySize; ++i) { const UFormElm *pEltOfList; if (pElt->getArrayNode (&pEltOfList, i) && pEltOfList) { const UFormElm *pEltPos; const UFormElm *pEltOrigin; if (pEltOfList->getNodeByName(&pEltPos, "Pos") && pEltOfList->getNodeByName(&pEltOrigin, "Origin")) { CCharacterSheet::CCastRay cr; if (pEltPos->getValueByName(cr.Pos.x, "X") && pEltPos->getValueByName(cr.Pos.y, "Y") && pEltPos->getValueByName(cr.Pos.z, "Z") && pEltOrigin->getValueByName(cr.Origin.x, "X") && pEltOrigin->getValueByName(cr.Origin.y, "Y") && pEltOrigin->getValueByName(cr.Origin.z, "Z") ) { ProjectileCastRay.push_back(cr); } } } } } if(!item.getValueByName(R2Npc, "r2_npc")) { R2Npc = false; debug("Key 'R2Npc' not found."); } }// build //