CvUnit::getCaptureDefinition(CvUnitCaptureDefinition *, PlayerTypes)
- Defined in
- CvUnit.cpp, line 1840
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_getCaptureDefinition
Hooks
static bool BeforeCvUnit_getCaptureDefinition(CvUnit* self, CvUnitCaptureDefinition* pkCaptureDef, PlayerTypes eCapturingPlayer, bool& result);static void AfterCvUnit_getCaptureDefinition(CvUnit* self, CvUnitCaptureDefinition* pkCaptureDef, PlayerTypes eCapturingPlayer, bool& result);static bool ReplaceCvUnit_getCaptureDefinition(bool (*original)(CvUnit*, CvUnitCaptureDefinition*, PlayerTypes), CvUnit* self, CvUnitCaptureDefinition* pkCaptureDef, PlayerTypes eCapturingPlayer);CivRegisterBefore<CivHooks::CvUnit_getCaptureDefinition>(host, &BeforeCvUnit_getCaptureDefinition);CivRegisterAfter<CivHooks::CvUnit_getCaptureDefinition>(host, &AfterCvUnit_getCaptureDefinition);CivRegisterReplace<CivHooks::CvUnit_getCaptureDefinition>(host, &ReplaceCvUnit_getCaptureDefinition);
Code
1839// Get a definition that can be used to create a captured version of the unit.1840bool CvUnit::getCaptureDefinition(CvUnitCaptureDefinition* pkCaptureDef, PlayerTypes eCapturingPlayer /* = NO_PLAYER */)1841{1842 CvUnitCaptureDefinition kCaptureDef;1843 kCaptureDef.eOldPlayer = getOwner();1844 kCaptureDef.eOriginalOwner = GetOriginalOwner();1845 kCaptureDef.eOldType = getUnitType();1846 kCaptureDef.eCapturingPlayer = (eCapturingPlayer != NO_PLAYER) ? eCapturingPlayer : getCapturingPlayer();1847 kCaptureDef.bEmbarked = m_bEmbarked;1848 kCaptureDef.eCaptureUnitType = NO_UNIT;1849#if defined(MOD_API_EXTENSIONS)1850 kCaptureDef.iScenarioData = m_iScenarioData;18511852 // If this is a GP with need to keep their details1853 if (IsGreatPerson()) {1854 kCaptureDef.sName = getName();1855#if defined(MOD_GLOBAL_NO_LOST_GREATWORKS)1856 kCaptureDef.sGreatName = getGreatName();1857#endif1858 kCaptureDef.eGreatWork = m_eGreatWork;1859 kCaptureDef.iTourismBlastStrength = m_iTourismBlastStrength;1860 }1861#endif18621863 if (GetReligionData())1864 {1865 kCaptureDef.eReligion = GetReligionData()->GetReligion();1866 kCaptureDef.iReligiousStrength = GetReligionData()->GetReligiousStrength();1867 kCaptureDef.iSpreadsLeft = GetReligionData()->GetSpreadsLeft();1868 }1869 1870 // Captured as is?1871 if(IsCapturedAsIs())1872 {1873 kCaptureDef.bAsIs = true;1874 kCaptureDef.eCaptureUnitType = getUnitType();1875 }18761877 // Barbs captured this unit, or a player capturing this unit from the barbs1878 else if(isBarbarian() || (kCaptureDef.eCapturingPlayer != NO_PLAYER && GET_PLAYER(kCaptureDef.eCapturingPlayer).isBarbarian()))1879 {1880 // Must be able to capture this unit normally... don't want the barbs picking up Workboats, Generals, etc.1881 if(kCaptureDef.eCapturingPlayer != NO_PLAYER && getCaptureUnitType(GET_PLAYER(kCaptureDef.eCapturingPlayer).getCivilizationType()) != NO_UNIT)1882 // Unit type is the same as what it was1883 kCaptureDef.eCaptureUnitType = getUnitType();1884 }18851886 // Barbs not involved1887 else1888 {1889 if(kCaptureDef.eCapturingPlayer != NO_PLAYER)1890 kCaptureDef.eCaptureUnitType = getCaptureUnitType(GET_PLAYER(kCaptureDef.eCapturingPlayer).getCivilizationType());1891 }18921893 CvPlot* pkPlot = plot();1894 if(pkPlot)1895 {1896 kCaptureDef.iX = pkPlot->getX();1897 kCaptureDef.iY = pkPlot->getY();1898 }1899 else1900 {1901 kCaptureDef.iX = INVALID_PLOT_COORD;1902 kCaptureDef.iY = INVALID_PLOT_COORD;1903 }19041905 if(pkCaptureDef)1906 *pkCaptureDef = kCaptureDef;19071908 return kCaptureDef.eCaptureUnitType != NO_UNIT && kCaptureDef.eCapturingPlayer != NO_PLAYER;1909}
Calls
- CvPlayer::getCivilizationType() const
- CvPlayer::isBarbarian() const
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPlot::getX() const
- CvPlot::getY() const
CvString::operator=- CvUnit::getCaptureUnitType(CivilizationTypes) const
- CvUnit::getCapturingPlayer() const
- CvUnit::getGreatName() const
- CvUnit::getName() const
- CvUnit::GetOriginalOwner() const
- CvUnit::getOwner() const
- CvUnit::GetReligionData() const
- CvUnit::getUnitType() const
- CvUnit::isBarbarian() const
- CvUnit::IsCapturedAsIs() const
- CvUnit::IsGreatPerson() const
- CvUnit::plot() const
- CvUnitCaptureDefinition::CvUnitCaptureDefinition()
CvUnitCaptureDefinition::operator=- CvUnitReligion::GetReligion() const
- CvUnitReligion::GetReligiousStrength() const
- CvUnitReligion::GetSpreadsLeft() const
FAutoVariable::operator const bool &