Merge remote-tracking branch 'origin/feature-new-forage-sbricks'

feature/prepare-cross-merge
Ulukyn 5 years ago committed by kaetemi
parent 1b5f2ed003
commit a3818593b8
No known key found for this signature in database
GPG Key ID: 9873C4D40BB479BC

@ -110,6 +110,7 @@ void CStaticBrick::serial(class NLMISC::IStream &f)
f.serial(ForbiddenExclude); f.serial(ForbiddenExclude);
f.serialCont( LearnRequiresOneOfSkills ); f.serialCont( LearnRequiresOneOfSkills );
f.serialCont( LearnRequiresSkills );
f.serialCont( LearnRequiresBricks ); f.serialCont( LearnRequiresBricks );
f.serialEnum( CivRestriction ); f.serialEnum( CivRestriction );
f.serial( Faction ); f.serial( Faction );
@ -421,6 +422,23 @@ void CStaticBrick::readStaticBrick( const NLGEORGES::UFormElm &root, const NLMIS
nlwarning( "<CStaticBrick::readGeorges> Invalid LearnRequiresOneOfSkills value '%s' in sheet %s", sav.c_str(), sheetId.toString().c_str() ); nlwarning( "<CStaticBrick::readGeorges> Invalid LearnRequiresOneOfSkills value '%s' in sheet %s", sav.c_str(), sheetId.toString().c_str() );
} }
// LearnRequiresSkills
if ( ! root.getValueByName (value, "Basics.LearnRequiresSkills") )
{
nlwarning("<CStaticBrick::readGeorges> can't get the value 'LearnRequireSkills' for sheet %s", sheetId.toString().c_str() );
}
skillsAndValues.clear();
explode( value, string(":"), skillsAndValues, true );
for ( vector<string>::const_iterator isv=skillsAndValues.begin(); isv!=skillsAndValues.end(); ++isv )
{
const string& sav = *isv;
CPlayerSkill ps;
if ( ps.initFromString( sav ) ) // discard the skill if unknown
LearnRequiresSkills.push_back( ps );
else
nlwarning( "<CStaticBrick::readGeorges> Invalid LearnRequiresSkills value '%s' in sheet %s", sav.c_str(), sheetId.toString().c_str() );
}
// LearnRequiresBricks // LearnRequiresBricks
if ( ! root.getValueByName (value, "Basics.LearnRequiresBricks") ) if ( ! root.getValueByName (value, "Basics.LearnRequiresBricks") )
{ {

@ -393,6 +393,9 @@ public:
/// Skills required to learn the brick (OR) /// Skills required to learn the brick (OR)
std::vector<CPlayerSkill> LearnRequiresOneOfSkills; std::vector<CPlayerSkill> LearnRequiresOneOfSkills;
/// Skills required to learn the brick (AND: all of them are required)
std::vector<CPlayerSkill> LearnRequiresSkills;
/// Bricks required to learn the brick (AND: all of them are required) /// Bricks required to learn the brick (AND: all of them are required)
std::vector<NLMISC::CSheetId> LearnRequiresBricks; std::vector<NLMISC::CSheetId> LearnRequiresBricks;

@ -55,6 +55,26 @@ inline bool skillRequiredAreBelowSkillValueLimit( uint skillValueLimit, const ve
} }
/*
* Find in skillsRequiredList that all skills are lower (by value) than the provided limit value
*/
inline bool skillsAreBelowSkillValueLimit( uint skillValueLimit, const vector<CPlayerSkill>& skillsRequiredList )
{
H_AUTO(skillsAreBelowSkillValueLimit);
vector<CPlayerSkill>::const_iterator irs;
for ( irs=skillsRequiredList.begin(); irs!=skillsRequiredList.end(); ++irs )
{
const CPlayerSkill& requiredSkill = *irs;
if ( ! requiredSkill.isSkillValueLowerThan( skillValueLimit ) )
{
return false;
}
}
return true;
}
/* /*
* Find in the player skill list has at least one skill that is higher than the provided skill. * Find in the player skill list has at least one skill that is higher than the provided skill.
* *
@ -87,6 +107,26 @@ inline bool skillRequiredMatchPlayerSkills( const vector<SSkill>& playerSkills,
} }
/*
* Find in skillsRequiredList that all skills match in player skills
*
* Precondition:
* - skillsRequiredList contains valid skills (not unknown)
*/
inline bool skillsMatchPlayerSkills( const vector<SSkill>& playerSkills, const vector<CPlayerSkill>& skillsRequiredList )
{
H_AUTO(skillsMatchPlayerSkills);
vector<CPlayerSkill>::const_iterator irs;
for ( irs=skillsRequiredList.begin(); irs!=skillsRequiredList.end(); ++irs )
{
const CPlayerSkill& requiredSkill = *irs;
if ( ! skillMatchesOneOfList( requiredSkill, playerSkills ) )
return false;
}
return true;
}
/* /*
* Check character fame against brick fame * Check character fame against brick fame
* *
@ -176,6 +216,16 @@ bool isPlayerAllowedToGetAllBricksFromPhrase( const CEntityId& eid,
return false; return false;
} }
if ( ! staticBrick->LearnRequiresSkills.empty() )
{
// Check if the brick is below or equal the skill value limit
if ( ! skillsAreBelowSkillValueLimit( skillValueLimit, staticBrick->LearnRequiresSkills ) )
return false;
// Check if all of the skills match one of the player's
if ( ! skillsMatchPlayerSkills( playerSkills, staticBrick->LearnRequiresSkills ) )
return false;
}
// Check if one of the fame required doesn't match with brick min fame value // Check if one of the fame required doesn't match with brick min fame value
if ( ! fameRequiredMatchPlayerFaction( eid, staticBrick->Faction, staticBrick->MinFameValue ) ) if ( ! fameRequiredMatchPlayerFaction( eid, staticBrick->Faction, staticBrick->MinFameValue ) )
return false; return false;

@ -219,6 +219,7 @@ bool CFgExtractionPhrase::build( const TDataSetRow & actorRowId, const std::vect
case TBrickParam::FG_ECT_SPC: case TBrickParam::FG_ECT_SPC:
INFOLOG("FG_ECT_SPC: %s",((CSBrickParamForageEcotypeSpec *)param)->Ecotype.c_str()); INFOLOG("FG_ECT_SPC: %s",((CSBrickParamForageEcotypeSpec *)param)->Ecotype.c_str());
_Props.Extraction.EcotypeSpec = ECOSYSTEM::stringToEcosystem( ((CSBrickParamForageEcotypeSpec *)param)->Ecotype ); _Props.Extraction.EcotypeSpec = ECOSYSTEM::stringToEcosystem( ((CSBrickParamForageEcotypeSpec *)param)->Ecotype );
_Props.Extraction.EcotypeSpecBonus = true;
break; break;
case TBrickParam::FG_RMGRP_FILT: case TBrickParam::FG_RMGRP_FILT:
INFOLOG("FG_RMGRP_FILT: %i",((CSBrickParamForageRMGroupFilter *)param)->Value); INFOLOG("FG_RMGRP_FILT: %i",((CSBrickParamForageRMGroupFilter *)param)->Value);
@ -294,7 +295,7 @@ bool CFgExtractionPhrase::build( const TDataSetRow & actorRowId, const std::vect
// else the phrase will be rejected in validate() // else the phrase will be rejected in validate()
} }
// Bonus: when using ecosystem specialization, decrease impact on some risks (TODO: linearly dependant on specialized skill value). // when using ecosystem specialization
if ( _Props.Extraction.EcotypeSpec != ECOSYSTEM::common_ecosystem ) if ( _Props.Extraction.EcotypeSpec != ECOSYSTEM::common_ecosystem )
{ {
// Check if the ecotype specialization matches // Check if the ecotype specialization matches
@ -303,6 +304,11 @@ bool CFgExtractionPhrase::build( const TDataSetRow & actorRowId, const std::vect
PHRASE_UTILITIES::sendDynamicSystemMessage( _ActorRowId, "FORAGE_ECOTYPE_SPEC_NOT_MATCHING" ); PHRASE_UTILITIES::sendDynamicSystemMessage( _ActorRowId, "FORAGE_ECOTYPE_SPEC_NOT_MATCHING" );
return false; return false;
} }
}
// Bonus: when using ecosystem/atys specialization, decrease impact on some risks (TODO: linearly dependant on specialized skill value).
if ( _Props.Extraction.EcotypeSpecBonus )
{
if ( _RequestedProps[CHarvestSource::A] != 0 ) if ( _RequestedProps[CHarvestSource::A] != 0 )
{ {
// Extraction // Extraction

@ -136,6 +136,9 @@ private:
/// Factor for increase speed of quality /// Factor for increase speed of quality
float QualitySlowFactor; float QualitySlowFactor;
/// True if terrain specialization or Atys specialization is used
bool EcotypeSpecBonus;
} Extraction; } Extraction;
struct struct

@ -289,6 +289,7 @@ bool CFgSearchPhrase::build( const TDataSetRow & actorRowId, const std::vector<
case TBrickParam::FG_ECT_SPC: case TBrickParam::FG_ECT_SPC:
INFOLOG("FG_ECT_SPC: %s",((CSBrickParamForageEcotypeSpec *)param)->Ecotype.c_str()); INFOLOG("FG_ECT_SPC: %s",((CSBrickParamForageEcotypeSpec *)param)->Ecotype.c_str());
_EcotypeSpec = ECOSYSTEM::stringToEcosystem( ((CSBrickParamForageEcotypeSpec *)param)->Ecotype ); _EcotypeSpec = ECOSYSTEM::stringToEcosystem( ((CSBrickParamForageEcotypeSpec *)param)->Ecotype );
_EcotypeSpecBonus = true;
break; break;
case TBrickParam::FG_RMGRP_FILT: case TBrickParam::FG_RMGRP_FILT:
INFOLOG("FG_RMGRP_FILT: %i",((CSBrickParamForageRMGroupFilter *)param)->Value); INFOLOG("FG_RMGRP_FILT: %i",((CSBrickParamForageRMGroupFilter *)param)->Value);
@ -800,7 +801,7 @@ uint CFgProspectionPhrase::generateSources( CCharacter *player )
CVector2f pos2f = pos; CVector2f pos2f = pos;
if ( hsource->init( _SourceIniProperties, pos2f, forageSite, depositForK, rawMaterial, quantityRatio ) ) if ( hsource->init( _SourceIniProperties, pos2f, forageSite, depositForK, rawMaterial, quantityRatio ) )
{ {
if ( _EcotypeSpec != ECOSYSTEM::common_ecosystem ) if ( _EcotypeSpecBonus )
hsource->setBonusForA( 20 ); hsource->setBonusForA( 20 );
if ( hsource->spawnBegin( _KnowledgePrecision, player->getEntityRowId(), false ) ) if ( hsource->spawnBegin( _KnowledgePrecision, player->getEntityRowId(), false ) )
@ -1030,7 +1031,7 @@ void CFgProspectionPhrase::startLocateDeposit( CCharacter *player )
CVector2f locatedPoint( retainedLoc->NearestPos ); CVector2f locatedPoint( retainedLoc->NearestPos );
TReportAction report; TReportAction report;
sint32 effectFocusCostByUpdate = _FocusCost / ForageFocusRatioOfLocateDeposit.get(); sint32 effectFocusCostByUpdate = _FocusCost / ForageFocusRatioOfLocateDeposit.get();
if ( _EcotypeSpec != ECOSYSTEM::common_ecosystem ) if ( _EcotypeSpecBonus )
effectFocusCostByUpdate /= 2; // lower focus consumption with terrain specialization effectFocusCostByUpdate /= 2; // lower focus consumption with terrain specialization
CSEffectLocateDeposit *effect = new CSEffectLocateDeposit( CSEffectLocateDeposit *effect = new CSEffectLocateDeposit(
player->getEntityRowId(), player->getEntityRowId(),

@ -144,6 +144,9 @@ protected: // because CSearchPhrase is a common trunc
/// Locator enabled /// Locator enabled
bool _IsLocateDepositProspection; bool _IsLocateDepositProspection;
/// True if terrain specialization or Atys specialization is used
bool _EcotypeSpecBonus;
}; };

Loading…
Cancel
Save