diff CastSpellInfo.cpp @ 2184:e0863f5beee0

SPELL_WATER_RECHARGE_ITEM
author Ritor1
date Fri, 24 Jan 2014 18:01:51 +0600
parents 172cfb4ee150
children 385040580292
line wrap: on
line diff
--- a/CastSpellInfo.cpp	Thu Jan 23 23:35:10 2014 +0600
+++ b/CastSpellInfo.cpp	Fri Jan 24 18:01:51 2014 +0600
@@ -285,6 +285,7 @@
   signed int a2; // [sp+E7Ch] [bp-8h]@14
   int amount; // [sp+E80h] [bp-4h]@1
   int obj_type;
+  ItemDesc* _item;
 
   SpriteObject pSpellSprite; // [sp+DDCh] [bp-A8h]@1
 
@@ -560,7 +561,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_AIR_IMPLOSION://Точечный взрыв
+      case SPELL_AIR_IMPLOSION://Точный взрыв
       {
         mon_id = PID_ID(a2);
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -716,7 +717,7 @@
       case SPELL_WATER_ACID_BURST://Всплеск кислоты
       case SPELL_EARTH_BLADES://Лезвия
       case SPELL_BODY_FLYING_FIST://Летающий кулак
-      case SPELL_DARK_TOXIC_CLOUD://Токсичное облако
+      case SPELL_DARK_TOXIC_CLOUD://Облако-токсин
       {
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
@@ -888,7 +889,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_FIRE_FIRE_AURA: //Наколить
+      case SPELL_FIRE_FIRE_AURA: //Аура огня
       {
         switch (skill_level)
         {
@@ -902,7 +903,7 @@
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
           break;
         v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
-        ItemDesc* _item = &pItemsTable->pItems[v730c->uItemID];
+        _item = &pItemsTable->pItems[v730c->uItemID];
         v730c->UpdateTempBonus(pParty->uTimePlayed);
         if ( v730c->uItemID < 64 || v730c->uItemID > 65 
          && !v730c->IsBroken()
@@ -1183,7 +1184,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_FIRE_METEOR_SHOWER://Поток метеоритов
+      case SPELL_FIRE_METEOR_SHOWER://Поток метеоров
       {
         //if (skill_level < 3)//для мастера и магистра
           //break;
@@ -1260,7 +1261,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_FIRE_INFERNO://Жар печи
+      case SPELL_FIRE_INFERNO://Адский огонь
       {
         if ( uCurrentlyLoadedLevelType == LEVEL_Outdoor)
         {
@@ -1300,7 +1301,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_AIR_WIZARD_EYE://Глаз колдуна
+      case SPELL_AIR_WIZARD_EYE://Око чародея
       {
         duration = 3600 * spell_level;
         if ( !pPlayer->CanCastSpell(uRequiredMana) )
@@ -1311,7 +1312,7 @@
         LODWORD(v727) = 1;
         break;
       }
-      case SPELL_AIR_FEATHER_FALL://Падение пёрышком
+      case SPELL_AIR_FEATHER_FALL://Падение пера(пёрышком)
       {
         switch (skill_level)
         {
@@ -1496,7 +1497,7 @@
           }
           else
           {
-            HIDWORD(v685) = stru_5C6E00->Atan2((signed __int64)sqrt(j * j + k * k), ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)));
+            HIDWORD(v685) = stru_5C6E00->Atan2((signed __int64)sqrt((float)(j * j + k * k)), ((double)a2 + (double)dist_Z - (double)(dist_Z + 2500)));
             LODWORD(v685) = stru_5C6E00->Atan2(j, k);
           }
           pSpellSprite.stru_24.Reset();
@@ -1637,282 +1638,271 @@
         LODWORD(v727) = 1;
        break;
       }
-      case SPELL_WATER_WATER_WALK:
+      case SPELL_WATER_WATER_WALK://Хождение по воде
+      {
+        if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          break;
+        }
+        switch (skill_level)
+        {
+          case 1: //break;
+          case 2: duration = 600 * spell_level; break;
+          case 3:
+          case 4: duration = 3600 * spell_level; break;
+          default:
+            assert(false);
+        }
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
+        pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
+        pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(duration << 7) * 0.033333335),
+                                       skill_level, amount, v169, pCastSpell->uPlayerID + 1);
+        if ( skill_level == 4 )
+          pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_WATER_RECHARGE_ITEM://Перезарядка
       {
-			if ( !pPlayers[pCastSpell->uPlayerID + 1]->GetMaxMana() )
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				break;
-			}
-			if ( skill_level == 2 || skill_level != 3 && skill_level != 4 )
-				v229 = 600 * spell_level;
-			else
-				v229 = 3600 * spell_level;
-			LODWORD(v733) = v229;
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			v169 = pOtherOverlayList->_4418B1(10005, 201, 0, 65536);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 0);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 1);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 2);
-			pGame->GetStru6()->SetPlayerBuffAnim(pCastSpell->uSpellID, 3);
-
-			pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].Apply(pParty->uTimePlayed + (signed int)(signed __int64)((double)(v229 << 7) * 0.033333335),
-				skill_level, amount, v169, pCastSpell->uPlayerID + 1);
-			if ( skill_level == 4 )
-				pParty->pPartyBuffs[PARTY_BUFF_WATER_WALK].uFlags = 1;
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_WATER_RECHARGE_ITEM:
-		{
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
-				break;
-			v240 = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
-			
-			if ( v240->GetItemEquipType() != 12 || v240->uAttributes & 2 )
-			{
-				_50C9D0_AfterEnchClickEventId = 113;
-				_50C9D4_AfterEnchClickEventSecondParam = 0;
-				_50C9D8_AfterEnchClickEventTimeout = 1;
-
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				continue;
-			}
-			if ( skill_level == 1 || skill_level == 2 )
-				v241 = (double)v723 * 0.0099999998 + 0.5;
-			else if ( skill_level == 3 )
-				v241 = (double)v723 * 0.0099999998 + 0.69999999;
-			else if ( skill_level == 4 )
-				v241 = (double)v723 * 0.0099999998 + 0.80000001;
-			else
-				v241 = 0.0;
-			if ( v241 > 1.0 )
-				v241 = 1.0;
-			int uNewCharges = v240->uMaxCharges * v241;
-			v240->uMaxCharges = uNewCharges;
-			v240->uNumCharges = uNewCharges;
-			if ( uNewCharges <= 0 )
-			{
-				v240 = 0;
-				_50C9D0_AfterEnchClickEventId = 113;
-				_50C9D4_AfterEnchClickEventSecondParam = 0;
-				_50C9D8_AfterEnchClickEventTimeout = 1;
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2u);
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				spell_level = v723;
-				continue;
-			}
-			v240->uAttributes |= 0x40u;
-			_50C9A8_item_enchantment_timer = 256;
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_WATER_ENCHANT_ITEM:
-		{
-			if ( !pPlayer->CanCastSpell(uRequiredMana) )
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        v730c = &pParty->pPlayers[pCastSpell->uPlayerID_2].pInventoryItemList[a2];
+        if ( v730c->GetItemEquipType() != 12 || v730c->uAttributes & 2 )
+        {
+          _50C9D0_AfterEnchClickEventId = 113;
+          _50C9D4_AfterEnchClickEventSecondParam = 0;
+          _50C9D8_AfterEnchClickEventTimeout = 1;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);  // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          continue;
+        }
+        if ( skill_level == 1 || skill_level == 2 )
+          v241 = (double)v723 * 0.0099999998 + 0.5;//50 %
+        else if ( skill_level == 3 )
+          v241 = (double)v723 * 0.0099999998 + 0.69999999;//30 %
+        else if ( skill_level == 4 )
+          v241 = (double)v723 * 0.0099999998 + 0.80000001;//20 %
+        else
+          v241 = 0.0;
+        if ( v241 > 1.0 )
+          v241 = 1.0;
+        int uNewCharges = v730c->uMaxCharges * v241;
+        v730c->uMaxCharges = uNewCharges;
+        v730c->uNumCharges = uNewCharges;
+        if ( uNewCharges <= 0 )
+        {
+          v730c = 0;
+          _50C9D0_AfterEnchClickEventId = 113;
+          _50C9D4_AfterEnchClickEventSecondParam = 0;
+          _50C9D8_AfterEnchClickEventTimeout = 1;
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2);//Не получилось!!!
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          spell_level = v723;
+          continue;
+        }
+        v730c->uAttributes |= 0x40u;
+        _50C9A8_item_enchantment_timer = 256;
+        LODWORD(v727) = 1;
         break;
-			uRequiredMana = 0;
-			amount = 10 * spell_level;
-			v730 = 1;
-			pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2];
-			v245 = &pPlayer->pInventoryItemList[a2];
-			ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID];
-			if ( 
-				skill_level == 1 || skill_level == 2 && _v725->uEquipType > 2 ||
-				skill_level == 3 || skill_level == 4 && 
-				v245->uItemID <= 134 &&
-				v245->uSpecEnchantmentType == 0 &&
-				v245->uEnchantmentType == 0 &&
-				v245->m_enchantmentStrength== 0 &&
-				!v245->IsBroken() )
-			{
-				if ( v245->GetValue() < 450 || 
-					(v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4) && _v725->uEquipType >= 0 && _v725->uEquipType <= 2)
-					)
-				{
-					v730 = 0;
-				}
- 
-                __debugbreak(); // castspellinfo.cpp(1962): warning C4700: uninitialized local variable 'v271' used
-				if ( rand() % 100 < 10 * spell_level || 
-					(rand() % 100 < 80 && (skill_level == 3 || skill_level == 4 )) ||
-					v245->GetValue() < 450 || 
-					(v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4) && v271 >= 0 && v271 <= 2)
-					)
-				{
-					v313 = _v725->uEquipType;
-					if ( _v725->uEquipType >= 3 && _v725->uEquipType <= 11 )
-					{
-						v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
-						v245->uEnchantmentType = 0;
-                        __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used
-						for ( kk = pItemsTable->pEnchantments[0].to_item[v245->GetItemEquipType() + 1];
-							;
-							kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[v245->GetItemEquipType() + 1] )
-						{
-							++v245->uEnchantmentType;
-							if ( kk >= v295 )
-								break;
-						}
-						v255 = 10;//pItemsTable->field_116D8[17];
-						v256 = 10;//pItemsTable->field_116D8[16];
-						v245->m_enchantmentStrength = v256 + rand() % (v255 - v256 + 1);
-						v245->uAttributes |= 0x20u;
-						_50C9A8_item_enchantment_timer = 256;
-						LODWORD(v727) = 1;
-						break;
-					}
-					else if ( skill_level == 3 || skill_level == 4)
-					{
-					v257 = pItemsTable->pSpecialEnchantments_count;
-					v258 = 0;
-					v725 = 0.0;
-					int _v733 = 0;
-					if ( pItemsTable->pSpecialEnchantments_count > 0 )
-					{
-						v730 = (int)&v679;
-						do
-						{
-							v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement);
-							if ( !v259 || v259 == 1 )
-							{
-								v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[v245->GetItemEquipType()
-																					+ 4]
-										+ v258 * 28);
-								LODWORD(v725) += v260;
-								if ( v260 )
-								{
-									v261 = v730;
-									v730 += 4;
-									*(int *)v261 = _v733;
-								}
-							}
-							++_v733;
-							++v258;
-						}
-						while ( _v733 < v257 );
-					}
-					v262 = rand() % SLODWORD(v725);
-					v263 = v679;
-					v245->uSpecEnchantmentType = v679[0];
-					v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[v245->GetItemEquipType() + 4];
-					v265 = v262 + 1;
-					if ( v264 < v265 )
-					{
-						for ( ii = v679; ; ii = (int *)v732 )
-						{
-							v267 = (int)(ii + 1);
-							v732 = v267;
-							v268 = *(int *)v267;
-							*(int *)(v245 + 12) = v268;
-							v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[v245->GetItemEquipType()
-																				+ 4];
-							if ( v264 >= v265 )
-								break;
-						}
-					}
-
-						v277 = pItemsTable->pSpecialEnchantments_count;
-						v278 = 0;
-						v725 = 0.0;
-						_v733 = 0;
-						if ( pItemsTable->pSpecialEnchantments_count > 0 )
-						{
-							int *_v730 = v679;
-							do
-							{
-								v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement);
-								if ( !v279 || v279 == 1 )
-								{
-									v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[v245->GetItemEquipType()]);
-									_v733 += v280;
-									if ( v280 )
-									{
-										v281 = _v730;
-										++_v730;
-										*v281 = _v733;
-									}
-								}
-								++_v733;
-								++v278;
-							}
-							while ( _v733 < v277 );
-						}
-						v282 = rand() % _v733;
-						v283 = v679;
-						v245->uSpecEnchantmentType = v679[0];
-						v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[v245->GetItemEquipType() ];
-						v285 = v282 + 1;
-						for ( l = v679; v284 < v285; ++l )
-						{
-							v245->uSpecEnchantmentType = *(l+1);
-							v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[v245->GetItemEquipType()];
-						}
-						++v245->uSpecEnchantmentType;
-						v245->uAttributes |= 0x20u;
-						_50C9A8_item_enchantment_timer = 256;
-						LODWORD(v727) = 1;
-						break;
-					}
-				}
-				else
-				{
-					if ( !(BYTE1(v245->uAttributes) & 2) )
-					{
-						v245->uAttributes |= 2;
-					}
-				}
-						
-			}
-
-			if ( LODWORD(v727) == 0 )
-			{
-				v317 = pGlobalTXT_LocalizationStrings[428];
-				if ( v730 == 0 )
-					v317 = pGlobalTXT_LocalizationStrings[585];
-				ShowStatusBarString(v317, 2u);
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				v318 =  &pParty->pPlayers[pCastSpell->uPlayerID_2];
-				pCastSpell->uSpellID = 0;
-				v318->PlaySound(SPEECH_43, 0);
-			}
-
-			break;
-		}
-		case SPELL_WATER_TOWN_PORTAL:
-		{
-			amount = 10 * spell_level;
-			if ( pPlayer->sMana < (signed int)uRequiredMana )
-				break;
-			if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && skill_level != 4 || rand() % 100 >= amount && skill_level != 4 )
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				continue;
-			}
-			town_portal_caster_id = LOBYTE(pCastSpell->uPlayerID);
-			pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
-			LODWORD(v727) = 1;
-			break;
-		}
-		case SPELL_WATER_LLOYDS_BEACON:
-		{
-			LODWORD(v733) = 604800 * spell_level;
-			if ( !_stricmp(pCurrentMapName, "d05.blv") )
-			{
-				ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
-				pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
-				pCastSpell->uSpellID = 0;
-				continue;
-			}
-			v319 = uRequiredMana;
-			if ( pPlayer->sMana >= (signed int)uRequiredMana )
+      }
+      case SPELL_WATER_ENCHANT_ITEM://Талисман
+      {
+        if ( !pPlayer->CanCastSpell(uRequiredMana) )
+          break;
+        uRequiredMana = 0;
+        amount = 10 * spell_level;
+        bool item_not_broken = true;
+        int rnd = rand() % 100;
+        pPlayer = &pParty->pPlayers[pCastSpell->uPlayerID_2];
+        v245 = &pPlayer->pInventoryItemList[a2];
+        ItemDesc *_v725 = &pItemsTable->pItems[v245->uItemID];
+        if ((skill_level == 1 || skill_level == 2 /*&& _v725->uEquipType > EQUIP_BOW*/ || skill_level == 3 || skill_level == 4) && 
+            v245->uItemID <= 134 &&
+            v245->uSpecEnchantmentType == 0 && v245->uEnchantmentType == 0 &&
+            v245->m_enchantmentStrength== 0 && !v245->IsBroken() )
+        {
+          if ( (v245->GetValue() < 450 && ( skill_level == 1 || skill_level == 2 ))
+          || (v245->GetValue() < 450 && (skill_level == 3|| skill_level == 4 ) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW)
+          || (v245->GetValue() < 250 && (skill_level == 3 || skill_level == 4 )&& _v725->uEquipType > EQUIP_BOW) )//Условия поломки
+          {
+            if ( !(v245->uAttributes & 0x200) )// предмет не сломан
+            {
+              v245->uAttributes |= 2;//теперь сломан
+            }
+            item_not_broken = false;
+          }
+          else
+          {
+            if ( rnd >= 10 * spell_level )//шанс на срабатывание
+            {
+              if ( !(v245->uAttributes & 0x200) )// предмет не сломан
+                v245->uAttributes |= 2;//теперь сломан
+            }
+            else
+            {
+            if ( (rnd < 80 && (skill_level == 3 || skill_level == 4 )) || v245->GetValue() < 450 || (v245->GetValue() < 250//Ritor1:здесь я остановился
+            && (skill_level == 3 || skill_level == 4) && _v725->uEquipType >= EQUIP_SINGLE_HANDED && _v725->uEquipType <= EQUIP_BOW))
+          {
+            v313 = _v725->uEquipType;
+            if ( _v725->uEquipType >= EQUIP_ARMOUR && _v725->uEquipType <= EQUIP_AMULET )
+            {
+              v295 = rand() % 10;// pItemsTable->field_116D8[pItemsTable->pItems[_this->uItemID].uEquipType];
+              /*v245->uEnchantmentType = 0;
+              __debugbreak(); // castspellinfo.cpp(1971): warning C4700: uninitialized local variable 'v294' used
+              for ( kk = pItemsTable->pEnchantments[0].to_item[v245->GetItemEquipType() + 1];
+                    ;
+                    kk += pItemsTable->pEnchantments[v294->uEnchantmentType].to_item[v245->GetItemEquipType() + 1] )
+              {
+                ++v245->uEnchantmentType;
+                if ( kk >= v295 )
+                  break;
+              }
+              v255 = 10;//pItemsTable->field_116D8[17];
+              v256 = 10;//pItemsTable->field_116D8[16];
+              v245->m_enchantmentStrength = v256 + rand() % (v255 - v256 + 1);*/
+              v245->uEnchantmentType = v295;
+              v245->m_enchantmentStrength = pItemsTable->pEnchantments[v295].to_item[_v725->uEquipType - EQUIP_ARMOUR];
+              v245->uAttributes |= 0x20u;
+              _50C9A8_item_enchantment_timer = 256;
+              LODWORD(v727) = 1;
+              break;
+            }
+            else if ( skill_level == 3 || skill_level == 4)
+            {
+              v258 = 0;
+              v725 = 0.0;
+              int _v733;
+              if ( pItemsTable->pSpecialEnchantments_count > 0 )
+              {
+                v730 = (int)&v679;
+                for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 )
+                {
+                  v259 = LOBYTE(pItemsTable->pSpecialEnchantments[v258 + 1].pBonusStatement);
+                  if ( !v259 || v259 == 1 )
+                  {
+                    v260 = *(&pItemsTable->pSpecialEnchantments[0].to_item_apply[v245->GetItemEquipType() + 4] + v258 * 28);
+                    LODWORD(v725) += v260;
+                    if ( v260 )
+                    {
+                      v261 = v730;
+                      v730 += 4;
+                      *(int *)v261 = _v733;
+                    }
+                  }
+                  ++v258;
+                }
+              }
+              v262 = rand() % SLODWORD(v725);
+              v263 = v679;
+              v245->uSpecEnchantmentType = v679[0];
+              v264 = pItemsTable->pSpecialEnchantments[*v263].to_item_apply[v245->GetItemEquipType() + 4];
+              v265 = v262 + 1;
+              if ( v264 < v265 )
+              {
+                for ( ii = v679; ; ii = (int *)v732 )
+                {
+                  v267 = (int)(ii + 1);
+                  v732 = v267;
+                  v268 = *(int *)v267;
+                  *(int *)(v245 + 12) = v268;
+                  v264 += pItemsTable->pSpecialEnchantments[v268].to_item_apply[v245->GetItemEquipType() + 4];
+                  if ( v264 >= v265 )
+                    break;
+                }
+              }
+              v278 = 0;
+              v725 = 0.0;
+              if ( pItemsTable->pSpecialEnchantments_count > 0 )
+              {
+                int *_v730 = v679;
+                for ( _v733 = 0; _v733 < pItemsTable->pSpecialEnchantments_count; ++_v733 )
+                {
+                  v279 = LOBYTE(pItemsTable->pSpecialEnchantments[v278].pBonusStatement);
+                  if ( !v279 || v279 == 1 )
+                  {
+                    v280 = *(&pItemsTable->pSpecialEnchantments[v278].to_item_apply[v245->GetItemEquipType()]);
+                    _v733 += v280;
+                    if ( v280 )
+                    {
+                      v281 = _v730;
+                      ++_v730;
+                      *v281 = _v733;
+                    }
+                  }
+                  ++v278;
+                }
+              }
+              v282 = rand() % _v733;
+              v283 = v679;
+              v245->uSpecEnchantmentType = v679[0];
+              v284 = pItemsTable->pSpecialEnchantments[*v283].to_item_apply[v245->GetItemEquipType() ];
+              v285 = v282 + 1;
+              for ( l = v679; v284 < v285; ++l )
+              {
+                v245->uSpecEnchantmentType = *(l+1);
+                v284 += pItemsTable->pSpecialEnchantments[*(l+1)].to_item_apply[v245->GetItemEquipType()];
+              }
+              ++v245->uSpecEnchantmentType;
+              v245->uAttributes |= 0x20u;
+              _50C9A8_item_enchantment_timer = 256;
+              LODWORD(v727) = 1;
+              break;
+            }
+          }
+		  }
+          }
+        }
+        if ( LODWORD(v727) == 0 )
+        {
+          v317 = pGlobalTXT_LocalizationStrings[428];//Не получилось!!!
+          if ( item_not_broken == false )
+            v317 = pGlobalTXT_LocalizationStrings[585];//Предмет недостаточно высокого качества
+          ShowStatusBarString(v317, 2);
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          //v318 =  &pParty->pPlayers[pCastSpell->uPlayerID_2];
+          pCastSpell->uSpellID = 0;
+          pParty->pPlayers[pCastSpell->uPlayerID_2].PlaySound(SPEECH_43, 0);
+        }
+        break;
+      }
+      case SPELL_WATER_TOWN_PORTAL://Портал города
+      {
+        amount = 10 * spell_level;
+        if ( pPlayer->sMana < (signed int)uRequiredMana )
+          break;
+        if ( pParty->uFlags & (PARTY_FLAGS_1_ALERT_RED | PARTY_FLAGS_1_ALERT_YELLOW) && skill_level != 4 || rand() % 100 >= amount && skill_level != 4 )
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          continue;
+        }
+        town_portal_caster_id = pCastSpell->uPlayerID;
+        pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastTownPortal, 0, 0);
+        LODWORD(v727) = 1;
+        break;
+      }
+      case SPELL_WATER_LLOYDS_BEACON://Маяк Ллойда
+      {
+        LODWORD(v733) = 604800 * spell_level;
+        if ( !_stricmp(pCurrentMapName, "d05.blv") )
+        {
+          ShowStatusBarString(pGlobalTXT_LocalizationStrings[428], 2); // Spell failed
+          pAudioPlayer->PlaySound(SOUND_PlayerCantCastSpell, 0, 0, -1, 0, 0, 0, 0);
+          pCastSpell->uSpellID = 0;
+          continue;
+        }
+        v319 = uRequiredMana;
+        if ( pPlayer->sMana >= (signed int)uRequiredMana )
 			{
 				pEventTimer->Pause();
 				pMessageQueue_50CBD0->AddMessage(UIMSG_OnCastLloydsBeacon, 0, 0);