void CShop::LoadFromDict(const idDict& dict) { // greebo: Assemble the difficulty prefix (e.g. "diff_0_") idStr diffPrefix = "diff_" + idStr(gameLocal.m_DifficultyManager.GetDifficultyLevel()) + "_"; if (dict.GetBool("shop_skip","0") || dict.GetBool(diffPrefix + "shop_skip","0")) { // if skip flag is set, skip the shop _skipShop = true; // No need to parse any further, the shop will be skipped anyway return; } // Check for loot carry-over rules LoadLootRules(dict); // Check for an "all-difficulty" gold value if (dict.FindKey("shop_gold_start") != NULL) { SetGold(dict.GetInt("shop_gold_start")); } // Try to retrieve the starting gold for the given difficulty level if (dict.FindKey(diffPrefix + "shop_gold_start") != NULL) { SetGold(dict.GetInt(diffPrefix + "shop_gold_start")); } // items for sale AddItems(dict, "shopItem", _itemsForSale); // starting items (items that player already has AddItems(dict, "startingItem", _startingItems); }
/// Update treasury for a turn void CvTreasury::DoGold() { int iGoldChange; iGoldChange = m_pPlayer->calculateGoldRateTimes100(); int iGoldAfterThisTurn = iGoldChange + GetGoldTimes100(); if(iGoldAfterThisTurn < 0) { SetGold(0); if(iGoldAfterThisTurn <= /*-5*/ GC.getDEFICIT_UNIT_DISBANDING_THRESHOLD() * 100) m_pPlayer->DoDeficit(); } else { ChangeGoldTimes100(iGoldChange); } // Update the amount of gold grossed across lifetime of game int iGrossGoldChange = CalculateGrossGold(); if(iGrossGoldChange > 0) { m_iLifetimeGrossGoldIncome += iGrossGoldChange; } FAssertMsg(m_GoldBalanceForTurnTimes100.size() <= (unsigned int) GC.getGame().getGameTurn(), "History of Gold Balances corrupted"); if(m_GoldBalanceForTurnTimes100.size() < (unsigned int) GC.getGame().getGameTurn()) { m_GoldBalanceForTurnTimes100.push_back(GetGoldTimes100()); } FAssertMsg(m_GoldChangeForTurnTimes100.size() <= (unsigned int) GC.getGame().getGameTurn(), "History of Gold Changes corrupted"); if(m_GoldChangeForTurnTimes100.size() < (unsigned int) GC.getGame().getGameTurn()) { m_GoldChangeForTurnTimes100.push_back(iGoldChange); } #if !defined(NO_ACHIEVEMENTS) if (m_pPlayer->isHuman() && !GC.getGame().isGameMultiPlayer()) { int iGoldDelta = (GetGoldFromCitiesTimes100(false) - GetGoldFromCitiesTimes100(true)) / 100; if (iGoldDelta >= 200) { gDLL->UnlockAchievement(ACHIEVEMENT_XP2_32); } } #endif }
void vMover::SetDestParam( int nDstParameter, int nAdjParameterValue, int nChgParameterValue, bool bSend ) { bool fSuccess = FALSE; if( (nDstParameter < 0 ) && ( nDstParameter != DST_ADJDEF_RATE && nDstParameter != DST_ADJDEF ) ) return; switch( nDstParameter ) { case DST_HP: { if( nAdjParameterValue == -1 ) SetPointParam( nDstParameter, GetMaxHitPoint() ); else SetPointParam( nDstParameter, GetHitPoint() + nAdjParameterValue ); } return; case DST_MP: { if( nAdjParameterValue == -1 ) SetPointParam( nDstParameter, GetMaxManaPoint() ); else SetPointParam( nDstParameter, GetManaPoint() + nAdjParameterValue ); } return; case DST_FP: { if( nAdjParameterValue == -1 ) SetPointParam( nDstParameter, GetMaxFatiguePoint() ); else SetPointParam( nDstParameter, GetFatiguePoint() + nAdjParameterValue ); } return; case DST_GOLD: Log( LOG_ERROR, "SetDestParam( DST_GOLD ) - [User:%s(%07d)], [Value:%d]", ((vUser*)(this))->GetName(), ((vUser*)(this))->m_idPlayer, nAdjParameterValue ); return; if( AddGold( nAdjParameterValue ) == FALSE ) SetGold( 0 ); return; case DST_RESIST_ALL: SetDestParam( DST_RESIST_ELECTRICITY, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_RESIST_FIRE, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_RESIST_WIND, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_RESIST_WATER, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_RESIST_EARTH, nAdjParameterValue, nChgParameterValue, bSend ); return; case DST_STAT_ALLUP: SetDestParam( DST_STR, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_DEX, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_INT, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_STA, nAdjParameterValue, nChgParameterValue, bSend ); return; case DST_HPDMG_UP: SetDestParam( DST_HP_MAX, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_CHR_DMG, nAdjParameterValue, nChgParameterValue, bSend ); return; case DST_DEFHITRATE_DOWN: SetDestParam( DST_ADJDEF, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_ADJ_HITRATE, nAdjParameterValue, nChgParameterValue, bSend ); return; case DST_LOCOMOTION: SetDestParam( DST_SPEED, nAdjParameterValue, nChgParameterValue, bSend ); SetDestParam( DST_JUMPING, ( nAdjParameterValue * 3 ), nChgParameterValue, bSend ); return; case DST_HP_RECOVERY_RATE: { int nMax = GetMaxOriginHitPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_HP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_MP_RECOVERY_RATE: { int nMax = GetMaxOriginManaPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_MP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_FP_RECOVERY_RATE: { int nMax = GetMaxOriginFatiguePoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_FP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_ALL_RECOVERY: { SetDestParam( DST_HP_RECOVERY, nAdjParameterValue, NULL_CHGPARAM, bSend ); SetDestParam( DST_MP_RECOVERY, nAdjParameterValue, NULL_CHGPARAM, bSend ); SetDestParam( DST_FP_RECOVERY, nAdjParameterValue, NULL_CHGPARAM, bSend ); } return; case DST_ALL_RECOVERY_RATE: { int nMax = GetMaxOriginHitPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_HP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); nMax = GetMaxOriginManaPoint(); nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_MP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); nMax = GetMaxOriginFatiguePoint(); nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_FP_RECOVERY, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_KILL_ALL: { SetDestParam( DST_KILL_HP, nAdjParameterValue, NULL_CHGPARAM, bSend ); SetDestParam( DST_KILL_MP, nAdjParameterValue, NULL_CHGPARAM, bSend ); SetDestParam( DST_KILL_FP, nAdjParameterValue, NULL_CHGPARAM, bSend ); } return; case DST_KILL_HP_RATE: { int nMax = GetMaxOriginHitPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_HP, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_KILL_MP_RATE: { int nMax = GetMaxOriginManaPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_MP, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_KILL_FP_RATE: { int nMax = GetMaxOriginFatiguePoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_FP, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_KILL_ALL_RATE: { int nMax = GetMaxOriginHitPoint(); int nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_HP, nRecv, NULL_CHGPARAM, bSend ); nMax = GetMaxOriginManaPoint(); nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_MP, nRecv, NULL_CHGPARAM, bSend ); nMax = GetMaxOriginFatiguePoint(); nRecv = (int)( (nMax * (nAdjParameterValue / 100.0f)) ); SetDestParam( DST_KILL_FP, nRecv, NULL_CHGPARAM, bSend ); } return; case DST_ALL_DEC_RATE: { SetDestParam( DST_MP_DEC_RATE, nAdjParameterValue, NULL_CHGPARAM, bSend ); SetDestParam( DST_FP_DEC_RATE, nAdjParameterValue, NULL_CHGPARAM, bSend ); } return; } if( nDstParameter >= MAX_ADJPARAMARY) return; if( nAdjParameterValue != 0 ) { fSuccess = true; switch( nDstParameter ) { case DST_CHRSTATE: case DST_IMMUNITY: if( nAdjParameterValue != NULL_ID ) { if( nAdjParameterValue == 0xffffffff ) { Log( LOG_ERROR, "SetDestParam : Adj == -1, %s", GetName() ); return; } m_adjParamAry[nDstParameter] |= nAdjParameterValue; } else fSuccess = false; break; case DST_CURECHR: ResetDestParam( DST_CHRSTATE, nAdjParameterValue, bSend ); return; case DST_REFLECT_DAMAGE: m_adjParamAry[nDstParameter] += nAdjParameterValue; m_chgParamAry[nDstParameter] = nChgParameterValue; break; case DST_CHR_CHANCEBLEEDING: case DST_CHR_CHANCESTEALHP: case DST_CHR_CHANCEPOISON: case DST_CHR_CHANCEDARK: case DST_CHR_CHANCESTUN: case DST_AUTOHP: m_adjParamAry[nDstParameter] += nAdjParameterValue; m_chgParamAry[nDstParameter] = nChgParameterValue; break; case DST_HEAL: m_nHealCnt = (short)( PROCESS_COUNT * 6.0f ); m_adjParamAry[nDstParameter] += nAdjParameterValue; break; default: m_adjParamAry[nDstParameter] += nAdjParameterValue; break; } } else if( nChgParameterValue != 0x7FFFFFFF ) { fSuccess = true; if( nDstParameter == DST_SPEED ) { if( m_chgParamAry[nDstParameter] == 0x7FFFFFFF ) m_chgParamAry[nDstParameter] = 0; m_chgParamAry[nDstParameter]++; } else m_chgParamAry[nDstParameter] = nChgParameterValue; } if( ( fSuccess & bSend ) == TRUE ) g_pUserMng.AddSetDestParam( this, nDstParameter, nAdjParameterValue, nChgParameterValue ); // if ( nAdjParameterValue == -1 ) // { // v6 = GetMaxHitPoint(); // SetPointParam( nDstParameter, v6, 0); // } // else // { // v7 = sub_646450(pThis); // CMover::SetPointParam(pThis, nDstParameter, nAdjParameterValue + v7, 0); // } // v5 = CMover::GetAdjParam(pThis, 94); // if ( v5 > 0 ) // { // CMover::ResetDestParam(pThis, 94, 0, 1); // v5 = sub_6396C0(pThis, 94); // } }