void CWeapon::reload (LPCSTR section) { CShootingObject::reload (section); CHudItemObject::reload (section); m_can_be_strapped = true; m_strapped_mode = false; if (pSettings->line_exist(section,"strap_bone0")) m_strap_bone0 = pSettings->r_string(section,"strap_bone0"); else m_can_be_strapped = false; if (pSettings->line_exist(section,"strap_bone1")) m_strap_bone1 = pSettings->r_string(section,"strap_bone1"); else m_can_be_strapped = false; if (m_eScopeStatus == ALife::eAddonAttachable) { m_addon_holder_range_modifier = READ_IF_EXISTS(pSettings,r_float,GetScopeName(),"holder_range_modifier",m_holder_range_modifier); m_addon_holder_fov_modifier = READ_IF_EXISTS(pSettings,r_float,GetScopeName(),"holder_fov_modifier",m_holder_fov_modifier); } else { m_addon_holder_range_modifier = m_holder_range_modifier; m_addon_holder_fov_modifier = m_holder_fov_modifier; } { Fvector pos,ypr; pos = pSettings->r_fvector3 (section,"position"); ypr = pSettings->r_fvector3 (section,"orientation"); ypr.mul (PI/180.f); m_Offset.setHPB (ypr.x,ypr.y,ypr.z); m_Offset.translate_over (pos); } m_StrapOffset = m_Offset; if (pSettings->line_exist(section,"strap_position") && pSettings->line_exist(section,"strap_orientation")) { Fvector pos,ypr; pos = pSettings->r_fvector3 (section,"strap_position"); ypr = pSettings->r_fvector3 (section,"strap_orientation"); ypr.mul (PI/180.f); m_StrapOffset.setHPB (ypr.x,ypr.y,ypr.z); m_StrapOffset.translate_over (pos); } else m_can_be_strapped = false; m_ef_main_weapon_type = READ_IF_EXISTS(pSettings,r_u32,section,"ef_main_weapon_type",u32(-1)); m_ef_weapon_type = READ_IF_EXISTS(pSettings,r_u32,section,"ef_weapon_type",u32(-1)); }
TagEntryPtr TagEntry::ReplaceSimpleMacro() { if(IsMacro()) { PPToken tok = TagsManagerST::Get()->GetDatabase()->GetMacro(GetName()); if(tok.flags & PPToken::IsValid && !(tok.flags & PPToken::IsFunctionLike)) { std::vector<TagEntryPtr> tags; TagsManagerST::Get()->FindByNameAndScope(tok.replacement, GetScopeName(), tags); if(tags.size() == 1) { // replace the current tag content with the new match return tags.at(0); } } } return NULL; }
float CWeapon::Weight() const { float res = CInventoryItemObject::Weight(); if(IsGrenadeLauncherAttached()&&GetGrenadeLauncherName().size()){ res += pSettings->r_float(GetGrenadeLauncherName(),"inv_weight"); } if(IsScopeAttached()&&m_scopes.size()){ res += pSettings->r_float(GetScopeName(),"inv_weight"); } if(IsSilencerAttached()&&GetSilencerName().size()){ res += pSettings->r_float(GetSilencerName(),"inv_weight"); } if(iAmmoElapsed) { float w = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"inv_weight"); float bs = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"box_size"); res += w*(iAmmoElapsed/bs); } return res; }
u32 CWeapon::Cost() const { u32 res = CInventoryItem::Cost(); if(IsGrenadeLauncherAttached()&&GetGrenadeLauncherName().size()){ res += pSettings->r_u32(GetGrenadeLauncherName(),"cost"); } if(IsScopeAttached()&&m_scopes.size()){ res += pSettings->r_u32(GetScopeName(),"cost"); } if(IsSilencerAttached()&&GetSilencerName().size()){ res += pSettings->r_u32(GetSilencerName(),"cost"); } if(iAmmoElapsed) { float w = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"cost"); float bs = pSettings->r_float(m_ammoTypes[m_ammoType].c_str(),"box_size"); res += iFloor(w*(iAmmoElapsed/bs)); } return res; }