@@ -4678,110 +4678,42 @@ setTmpValue(now);
46784678
46794679// ------------------------------------------------------------------------------------------------
46804680// ------------------------------------------------------------------------------------------------
4681- void AIUpdateInterface::evaluateMoraleBonusImpl ( Bool inHorde, Bool allowNationalism, Bool classicImplementation )
4681+ Bool AIUpdateInterface::hasNationalism () const
46824682{
4683- Object *us = getObject ();
4684-
4685- #ifdef ALLOW_DEMORALIZE
4686- // if we are are not demoralized we can have horde and nationalism effects
4687- if ( !isDemoralized () )
4688- #endif
4683+ if (const Player *player = getObject ()->getControllingPlayer ())
46894684 {
4690- Player *player = us->getControllingPlayer ();
4691-
4692- Bool nationalism;
4693- Bool fanaticism;
4685+ // /@todo Find a better way to represent nationalism without hard coding here (CBD)
4686+ static const UpgradeTemplate *nationalismTemplate = TheUpgradeCenter->findUpgrade ( " Upgrade_Nationalism" );
4687+ DEBUG_ASSERTCRASH ( nationalismTemplate != NULL , (" AIUpdateInterface::evaluateMoraleBonusImpl - Nationalism upgrade not found" ) );
4688+ return player->hasUpgradeComplete ( nationalismTemplate );
4689+ }
4690+ return false ;
4691+ }
46944692
4695- if (player && allowNationalism)
4696- {
4697- // do we have nationalism
4698- // /@todo Find a better way to represent nationalism without hard coding here (CBD)
4699- static const UpgradeTemplate *nationalismTemplate = TheUpgradeCenter->findUpgrade ( " Upgrade_Nationalism" );
4700- DEBUG_ASSERTCRASH ( nationalismTemplate != NULL , (" AIUpdateInterface::evaluateMoraleBonusImpl - Nationalism upgrade not found" ) );
4701- nationalism = player->hasUpgradeComplete ( nationalismTemplate );
4702-
4703- // do we have fanaticism
4704- // /@todo Find a better way to represent fanaticism without hard coding here (MAL)
4705- static const UpgradeTemplate *fanaticismTemplate = TheUpgradeCenter->findUpgrade ( " Upgrade_Fanaticism" );
4706- DEBUG_ASSERTCRASH ( fanaticismTemplate != NULL , (" AIUpdateInterface::evaluateMoraleBonusImpl - Fanaticism upgrade not found" ) );
4707- fanaticism = player->hasUpgradeComplete ( fanaticismTemplate );
4708- }
4709- else
4710- {
4711- nationalism = FALSE ;
4712- fanaticism = FALSE ;
4713- }
4693+ // ------------------------------------------------------------------------------------------------
4694+ // ------------------------------------------------------------------------------------------------
4695+ Bool AIUpdateInterface::hasFanaticism () const
4696+ {
4697+ if (const Player *player = getObject ()->getControllingPlayer ())
4698+ {
4699+ // /@todo Find a better way to represent fanaticism without hard coding here (MAL)
4700+ static const UpgradeTemplate *fanaticismTemplate = TheUpgradeCenter->findUpgrade ( " Upgrade_Fanaticism" );
4701+ DEBUG_ASSERTCRASH ( fanaticismTemplate != NULL , (" AIUpdateInterface::evaluateMoraleBonusImpl - Fanaticism upgrade not found" ) );
4702+ return player->hasUpgradeComplete ( fanaticismTemplate );
4703+ }
4704+ return false ;
4705+ }
47144706
4707+ // ------------------------------------------------------------------------------------------------
4708+ // ------------------------------------------------------------------------------------------------
4709+ void AIUpdateInterface::evaluateMoraleBonus ( Bool inHorde, Bool allowNationalism, HordeActionType type )
4710+ {
47154711#ifdef ALLOW_DEMORALIZE
4716- // demoralized
4717- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_DEMORALIZED );
4718- #endif
4719-
4720- // Lorenzen temporarily disabled, since it fights with the horde buff
4721- // Drawable *draw = us->getDrawable();
4722- // if ( draw && !us->isKindOf( KINDOF_PORTABLE_STRUCTURE ) )
4723- // draw->setTerrainDecal(TERRAIN_DECAL_NONE);
4724-
4725- if (classicImplementation)
4726- {
4727- // TheSuperHackers @info The classic implementation.
4728- // Is not great, because Nationalism and Fanaticism bonuses are not disabled when leaving the horde.
4729-
4730- if ( inHorde )
4731- {
4732- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4733- }
4734- else
4735- {
4736- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4737- }
4738-
4739- if ( nationalism )
4740- {
4741- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4742-
4743- if ( fanaticism )
4744- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4745- else
4746- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4747- }
4748- else
4749- {
4750- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4751- }
4752- }
4753- else
4754- {
4755- // TheSuperHackers @bugfix The fixed implementation.
4756- // Nationalism and Fanaticism are now tied to the horde status.
4757- // And Fanaticism is no longer dependent on Nationalism.
4758-
4759- if ( inHorde )
4760- {
4761- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4762-
4763- if ( nationalism )
4764- {
4765- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4766- }
47674712
4768- if ( fanaticism )
4769- {
4770- us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4771- }
4772- }
4773- else
4774- {
4775- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4776- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4777- us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4778- }
4779- }
4780-
4781- }
4782- #ifdef ALLOW_DEMORALIZE
4783- else
4713+ // if we are demoralized, then we can not have horde and nationalism effects
4714+ if ( isDemoralized () )
47844715 {
4716+ Object *us = getObject ();
47854717
47864718 // demoralized
47874719 us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_DEMORALIZED );
@@ -4797,28 +4729,100 @@ void AIUpdateInterface::evaluateMoraleBonusImpl( Bool inHorde, Bool allowNationa
47974729 draw->setTerrainDecal (TERRAIN_DECAL_DEMORALIZED);
47984730 }
47994731
4732+ return ;
48004733 }
4801- #endif
48024734
4803- }
4735+ // demoralized
4736+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_DEMORALIZED );
4737+
4738+ #endif // ALLOW_DEMORALIZE
4739+
4740+ // Lorenzen temporarily disabled, since it fights with the horde buff
4741+ // Object *us = getObject();
4742+ // Drawable *draw = us->getDrawable();
4743+ // if ( draw && !us->isKindOf( KINDOF_PORTABLE_STRUCTURE ) )
4744+ // draw->setTerrainDecal(TERRAIN_DECAL_NONE);
48044745
4805- // ------------------------------------------------------------------------------------------------
4806- // ------------------------------------------------------------------------------------------------
4807- void AIUpdateInterface::evaluateMoraleBonus ( Bool inHorde, Bool allowNationalism, HordeActionType type )
4808- {
48094746 switch (type)
48104747 {
48114748 case HORDEACTION_HORDE:
4812- evaluateMoraleBonusImpl (inHorde, allowNationalism, TRUE );
4749+ evaluateNationalismBonusClassic (inHorde, allowNationalism);
48134750 break ;
48144751
48154752 default :
48164753 case HORDEACTION_HORDE_FIXED:
4817- evaluateMoraleBonusImpl (inHorde, allowNationalism, FALSE );
4754+ evaluateNationalismBonus (inHorde, allowNationalism);
48184755 break ;
48194756 }
48204757}
48214758
4759+ // ------------------------------------------------------------------------------------------------
4760+ // TheSuperHackers @info The classic Nationalism Bonus implementation.
4761+ // Is not great, because Nationalism and Fanaticism bonuses are not disabled when leaving the horde.
4762+ // ------------------------------------------------------------------------------------------------
4763+ void AIUpdateInterface::evaluateNationalismBonusClassic ( Bool inHorde, Bool allowNationalism )
4764+ {
4765+ Object *us = getObject ();
4766+
4767+ if ( inHorde )
4768+ {
4769+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4770+ }
4771+ else
4772+ {
4773+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4774+ }
4775+
4776+ if ( allowNationalism && hasNationalism () )
4777+ {
4778+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4779+
4780+ if ( hasFanaticism () )
4781+ {
4782+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4783+ }
4784+ else
4785+ {
4786+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4787+ }
4788+ }
4789+ else
4790+ {
4791+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4792+ }
4793+ }
4794+
4795+ // ------------------------------------------------------------------------------------------------
4796+ // TheSuperHackers @bugfix The fixed Nationalism Bonus implementation.
4797+ // Nationalism and Fanaticism are now tied to the horde status.
4798+ // And Fanaticism is no longer dependent on Nationalism.
4799+ // ------------------------------------------------------------------------------------------------
4800+ void AIUpdateInterface::evaluateNationalismBonus ( Bool inHorde, Bool allowNationalism )
4801+ {
4802+ Object *us = getObject ();
4803+
4804+ if ( inHorde )
4805+ {
4806+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4807+
4808+ if ( allowNationalism && hasNationalism () )
4809+ {
4810+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4811+ }
4812+
4813+ if ( allowNationalism && hasFanaticism () )
4814+ {
4815+ us->setWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4816+ }
4817+ }
4818+ else
4819+ {
4820+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_HORDE );
4821+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_NATIONALISM );
4822+ us->clearWeaponBonusCondition ( WEAPONBONUSCONDITION_FANATICISM );
4823+ }
4824+ }
4825+
48224826#ifdef ALLOW_DEMORALIZE
48234827// ------------------------------------------------------------------------------------------------
48244828// ------------------------------------------------------------------------------------------------
0 commit comments