Mercurial > mm7
changeset 1790:5ace90f129d3
Player::AddVariable value capping done with calls to min, setplayerbuffanim and playsound contition variables removed
author | Grumpy7 |
---|---|
date | Thu, 03 Oct 2013 08:32:59 +0200 |
parents | 4d70df78baca |
children | 9f610f471283 |
files | Player.cpp |
diffstat | 1 files changed, 88 insertions(+), 240 deletions(-) [+] |
line wrap: on
line diff
--- a/Player.cpp Thu Oct 03 08:06:29 2013 +0200 +++ b/Player.cpp Thu Oct 03 08:32:59 2013 +0200 @@ -6040,7 +6040,6 @@ signed int v28; // eax@176 int v29; // [sp-8h] [bp-40h]@84 // signed int v30; // [sp-4h] [bp-3Ch]@4 - int v31; // [sp-4h] [bp-3Ch]@84 ItemGen item; // [sp+Ch] [bp-2Ch]@45 unsigned int v33; // [sp+30h] [bp-8h]@34 char v34; // [sp+37h] [bp-1h]@1 @@ -6066,14 +6065,14 @@ switch ( var_type ) { case VAR_RandomGold: - if ( !val ) + if ( val == 0 ) val = 1; v6 = rand(); party_finds_gold(v6 % val + 1, 1); GameUI_DrawFoodAndGold(); return; case VAR_RandomFood: - if ( !val ) + if ( val == 0 ) val = 1; v7 = rand() % val + 1; Party::GiveFood(v7); @@ -6093,63 +6092,37 @@ PlayAwardSound(uPlayerIdx); return; case VAR_CurrentHP: - v8 = &this->sHealth; - *v8 += val; - if ( this->sHealth <= this->GetMaxHealth() ) - { - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - PlayAwardSound(uPlayerIdx); - return; - } - v9 = this->GetMaxHealth(); - *v8 = v9; + this->sHealth = min(this->sHealth + val, this->GetMaxHealth() ); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_MaxHP: - v10 = this->GetMaxHealth(); this->_health_related = 0; this->uFullHealthBonus = 0; - this->sHealth = v10; + this->sHealth = this->GetMaxHealth(); return; case VAR_CurrentSP: - v8 = &this->sMana; - *v8 += val; - if ( this->sMana > GetMaxMana() ) - { - v9 = this->GetMaxMana(); - *v8 = v9; - } + this->sMana = min(this->sMana + val, this->GetMaxMana() ); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_MaxSP: - v11 = GetMaxMana(); this->_mana_related = 0; this->uFullManaBonus = 0; - this->sMana = v11; + this->sMana = GetMaxMana(); return; case VAR_ACModifier: - v12 = &this->sACModifier; - *v12 += val; - if ( *v12 > 255 ) - *v12 = 255; + this->sACModifier = min(this->sACModifier + val, 255); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseLevel: - v12 = (__int16 *)&this->uLevel; - *v12 += val; - if ( *v12 > 255 ) - *v12 = 255; + this->uLevel = min(this->uLevel + val, 255); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_LevelModifier: - v12 = &this->sLevelModifier; - *v12 += val; - if ( *v12 > 255 ) - *v12 = 255; + this->sLevelModifier = min(this->sLevelModifier + val, 255); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; @@ -6159,52 +6132,26 @@ case VAR_Award: if (_449B57_test_bit(this->_achieved_awards_bits, val) && pAwards[val].pText ) { - v34 = 1; - v3 = 1; this->PlaySound(SPEECH_96, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); } - v15 = (char *)this->_achieved_awards_bits; - _449B7E_toggle_bit((unsigned char *)v15, val, 1); - if ( v34 != 1 ) - { - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); - return; - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); + _449B7E_toggle_bit(this->_achieved_awards_bits, val, 1); return; case VAR_Experience: - this->uExperience += val; - if ( this->uExperience > 4000000000i64 ) - this->uExperience = 4000000000i64; + this->uExperience = min(this->uExperience + val, 4000000000i64); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_QBits_QuestsDone: if ( !_449B57_test_bit(pParty->_quest_bits, val) && pQuestTable[val] ) { - //v17 = pPlayers[uPlayerIdx + 1]; bFlashQuestBook = 1; - v34 = 1; - v3 = 1; this->PlaySound(SPEECH_93, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); } _449B7E_toggle_bit(pParty->_quest_bits, val, 1); - if ( v34 != 1 ) - { - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); - return; - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); return; case VAR_PlayerItemInHands: item.Reset(); @@ -6223,64 +6170,43 @@ party_finds_gold(val, 1); return; case VAR_BaseMight: - v18 = (__int16 *)&this->uMight; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uMight = min(this->uMight + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseIntellect: - v18 = (__int16 *)&this->uIntelligence; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uIntelligence = min(this->uIntelligence + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BasePersonality: - v18 = (__int16 *)&this->uWillpower; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uWillpower = min(this->uWillpower + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseEndurance: - v18 = (__int16 *)&this->uEndurance; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uEndurance = min(this->uEndurance + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseSpeed: - v18 = (__int16 *)&this->uSpeed; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uSpeed = min(this->uSpeed + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseAccuracy: - v18 = (__int16 *)&this->uAccuracy; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uAccuracy = min(this->uAccuracy + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BaseLuck: - v18 = (__int16 *)&this->uLuck; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->uLuck = min(this->uLuck + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); @@ -6313,12 +6239,8 @@ return; } LABEL_62: - v19 = (__int16 *)&this->uMightBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uMightBonus = min(this->uMightBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; @@ -6331,156 +6253,102 @@ { case VAR_ActualIntellect: LABEL_66: - v19 = (__int16 *)&this->uIntelligenceBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uIntelligenceBonus = min(this->uIntelligenceBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_ActualPersonality: LABEL_67: - v19 = (__int16 *)&this->uWillpowerBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uWillpowerBonus = min(this->uWillpowerBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_ActualEndurance: LABEL_68: - v19 = (__int16 *)&this->uEnduranceBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uEnduranceBonus = min(this->uEnduranceBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_ActualSpeed: LABEL_69: - v19 = (__int16 *)&this->uSpeedBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uSpeedBonus = min(this->uSpeedBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_ActualAccuracy: LABEL_70: - v19 = (__int16 *)&this->uAccuracyBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uAccuracyBonus = min(this->uAccuracyBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_ActualLuck: LABEL_71: - v19 = (__int16 *)&this->uLuckBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->uLuckBonus = min(this->uLuckBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_FireResistance: - v18 = &this->sResFireBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResFireBase = min(this->sResFireBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_AirResistance: - v18 = &this->sResAirBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResAirBase = min(this->sResAirBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_WaterResistance: - v18 = &this->sResWaterBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResWaterBase = min(this->sResWaterBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_EarthResistance: - v18 = &this->sResEarthBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResEarthBase = min(this->sResEarthBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_SpiritResistance: - v18 = &this->sResSpiritBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResSpiritBase = min(this->sResSpiritBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_MindResistance: - v18 = &this->sResMindBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResMindBase = min(this->sResMindBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_BodyResistance: - v18 = &this->sResBodyBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResBodyBase = min(this->sResBodyBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_LightResistance: - v18 = &this->sResLightBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResLightBase = min(this->sResLightBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_DarkResistance: - v18 = &this->sResDarkBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResDarkBase = min(this->sResDarkBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; case VAR_MagicResistance: - v18 = &this->sResMagicBase; - *v18 += val; - if ( *v18 > 255 ) - *v18 = 255; + this->sResMagicBase = min(this->sResMagicBase + val, 255); this->PlaySound(SPEECH_92, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); @@ -6490,12 +6358,8 @@ } return; } - v19 = &this->sResFireBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->sResFireBonus = min(this->sResFireBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; @@ -6509,67 +6373,73 @@ switch ( var_type ) { case VAR_BodyResistanceBonus: - v19 = &this->sResBodyBonus; - break; + this->sResBodyBonus = min(this->sResBodyBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_AirResistanceBonus: - v19 = &this->sResAirBonus; - break; + this->sResAirBonus = min(this->sResAirBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_WaterResistanceBonus: - v19 = &this->sResWaterBonus; - break; + this->sResWaterBonus = min(this->sResWaterBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_EarthResistanceBonus: - v19 = &this->sResEarthBonus; - break; + this->sResEarthBonus = min(this->sResEarthBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; case VAR_SpiritResistanceBonus: - v19 = &this->sResSpiritBonus; + this->sResSpiritBonus = min(this->sResSpiritBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; + case VAR_MindResistanceBonus: + this->sResMindBonus = min(this->sResMindBonus + val, 255); + this->PlaySound(SPEECH_91, 0); + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); + PlayAwardSound(uPlayerIdx); + return; break; default: - if ( var_type != 62 ) - return; - v19 = &this->sResMindBonus; - break; + return; } *v19 += val; if ( *v19 > 255 ) *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; } if ( var_type == VAR_LightResistanceBonus ) { - v19 = &this->sResLightBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->sResLightBonus = min(this->sResLightBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; } if ( var_type == VAR_DarkResistanceBonus ) { - v19 = &this->sResDarkBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->sResDarkBonus = min(this->sResDarkBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; } if ( var_type == VAR_MagicResistanceBonus ) { - v19 = &this->sResMagicBonus; - *v19 += val; - if ( *v19 > 255 ) - *v19 = 255; - v31 = 0; - this->PlaySound(SPEECH_91, v31); + this->sResMagicBonus = min(this->sResMagicBonus + val, 255); + this->PlaySound(SPEECH_91, 0); pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); PlayAwardSound(uPlayerIdx); return; @@ -6642,24 +6512,13 @@ } if ( !_449B57_test_bit(pParty->_autonote_bits, val) && pAutonoteTxt[val].pText ) { - v34 = 1; this->PlaySound(SPEECH_96, 0); //v24 = pAutonoteTxt[val].eType;//dword_72371C[2 * val]; bFlashAutonotesBook = 1; _506568_autonote_type = pAutonoteTxt[val].eType; + pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); } _449B7E_toggle_bit(pParty->_autonote_bits, val, 1); - v3 = 1; - if ( v34 != 1 ) - { - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); - return; - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - if ( v3 != 1 ) - return; PlayAwardSound(uPlayerIdx); return; } @@ -6668,17 +6527,6 @@ if ( var_type == 307 ) { pParty->uNumDeaths += val; - if ( v34 != 1 ) - { - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); - return; - } - pGame->pStru6Instance->SetPlayerBuffAnim(0x97u, uPlayerIdx); - if ( v3 != 1 ) - return; - PlayAwardSound(uPlayerIdx); return; } switch ( var_type )