CvUnit::promote(PromotionTypes, int)
- Defined in
- CvUnit.cpp, line 10690
- Class
- CvUnit
- Hook name
CivHooks::CvUnit_promote- Lua events
GameEvents.UnitPromoted
Hooks
static bool BeforeCvUnit_promote(CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId);static void AfterCvUnit_promote(CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId);static void ReplaceCvUnit_promote(void (*original)(CvUnit*, PromotionTypes, int), CvUnit* self, PromotionTypes ePromotion, int iLeaderUnitId);CivRegisterBefore<CivHooks::CvUnit_promote>(host, &BeforeCvUnit_promote);CivRegisterAfter<CivHooks::CvUnit_promote>(host, &AfterCvUnit_promote);CivRegisterReplace<CivHooks::CvUnit_promote>(host, &ReplaceCvUnit_promote);
Code
10690void CvUnit::promote(PromotionTypes ePromotion, int iLeaderUnitId)10691{10692 VALIDATE_OBJECT1069310694 CvPromotionEntry* pkPromotionInfo = GC.getPromotionInfo(ePromotion);10695 if(pkPromotionInfo == NULL)10696 {10697 return;10698 }1069910700 if(!canPromote(ePromotion, iLeaderUnitId))10701 {10702 return;10703 }1070410705 if(iLeaderUnitId >= 0)10706 {10707 UnitHandle pWarlord = GET_PLAYER(getOwner()).getUnit(iLeaderUnitId);10708 if(pWarlord)10709 {10710 pWarlord->giveExperience();10711 if(!pWarlord->getNameNoDesc().empty())10712 {10713 setName(pWarlord->getName());10714 }1071510716 //update graphics models10717 m_eLeaderUnitType = pWarlord->getUnitType();10718 }10719 }1072010721 if(!pkPromotionInfo->IsLeader())10722 {10723 changeLevel(1);10724 }1072510726 // Insta-Heal: never earned10727 if(pkPromotionInfo->IsInstaHeal())10728 {10729 changeDamage(-GC.getINSTA_HEAL_RATE());10730 }10731 // Set that we have this Promotion10732 else10733 {10734 setHasPromotion(ePromotion, true);1073510736#if defined(MOD_EVENTS_UNIT_UPGRADES)10737 if (MOD_EVENTS_UNIT_UPGRADES) {10738 GAMEEVENTINVOKE_HOOK(GAMEEVENT_UnitPromoted, getOwner(), GetID(), ePromotion);10739 } else {10740#endif10741 ICvEngineScriptSystem1* pkScriptSystem = gDLL->GetScriptSystem();10742 if (pkScriptSystem)10743 {10744 CvLuaArgsHandle args;10745 args->Push(((int)getOwner()));10746 args->Push(GetID());10747 args->Push(ePromotion);1074810749 bool bResult;10750 LuaSupport::CallHook(pkScriptSystem, "UnitPromoted", args.get(), bResult);10751 }10752#if defined(MOD_EVENTS_UNIT_UPGRADES)10753 }10754#endif10755 }1075610757 testPromotionReady();1075810759 if(IsSelected())10760 {10761 DLLUI->setDirty(UnitInfo_DIRTY_BIT, true);10762 }10763 else10764 {10765 setInfoBarDirty(true);10766 }10767}
Calls
- CustomMods::eventHook(const char *, const char *, ...)
- CustomMods::isEVENTS_UNIT_UPGRADES()
- CvGlobals::getDLLIFace()
- CvGlobals::GetEngineUserInterface()
- CvGlobals::getINSTA_HEAL_RATE()
- CvGlobals::getPromotionInfo(PromotionTypes)
- CvLuaArgsHandle::CvLuaArgsHandle()
- CvLuaArgsHandle::get() const
- CvLuaArgsHandle::operator->() const
- CvPlayer::getUnit(int)
- CvPlayerAI::getPlayer(PlayerTypes)
- CvPromotionEntry::IsInstaHeal() const
- CvPromotionEntry::IsLeader() const
- CvUnit::canPromote(PromotionTypes, int) const
- CvUnit::changeDamage(int, PlayerTypes, int, float, const CvString *)
- CvUnit::changeLevel(int)
- CvUnit::GetID() const
- CvUnit::getName() const
- CvUnit::getNameNoDesc() const
- CvUnit::getOwner() const
- CvUnit::getUnitType() const
- CvUnit::giveExperience()
- CvUnit::IsSelected() const
- CvUnit::setHasPromotion(PromotionTypes, bool)
- CvUnit::setInfoBarDirty(bool)
CvUnit::setName- CvUnit::testPromotionReady()
FAutoVariable::operator=FObjectHandle::FObjectHandleFObjectHandle::operator boolFObjectHandle::operator->ICvEngineScriptSystemArgs1::PushICvEngineUtility1::GetScriptSystemICvUserInterface1::setDirty- LuaSupport::CallHook(ICvEngineScriptSystem1 *, const char *, ICvEngineScriptSystemArgs1 *, bool &)
std::basic_string::empty