Răsfoiți Sursa

Fixed #849. Fixed buying artifacts for free.
Minor tweaks.

DjWarmonger 13 ani în urmă
părinte
comite
56c56f81e3
3 a modificat fișierele cu 16 adăugiri și 19 ștergeri
  1. 12 6
      client/GUIClasses.cpp
  2. 2 10
      config/creatures.json
  3. 2 3
      lib/CObjectHandler.cpp

+ 12 - 6
client/GUIClasses.cpp

@@ -2883,12 +2883,18 @@ void CMarketplaceWindow::makeDeal()
 		return;
 
 	int leftIdToSend = -1;
-	if(mode == EMarketMode::CREATURE_RESOURCE)
-		leftIdToSend = hLeft->serial;
-	else if(mode == EMarketMode::ARTIFACT_RESOURCE)
-		leftIdToSend = hLeft->getArtInstance()->id;
-	else
-		leftIdToSend = hLeft->id;
+	switch (mode)
+	{
+		case EMarketMode::CREATURE_RESOURCE:
+			leftIdToSend = hLeft->serial;
+			break;
+		case EMarketMode::ARTIFACT_RESOURCE:
+			leftIdToSend = hLeft->getArtInstance()->id;
+			break;
+		default:
+			leftIdToSend = hLeft->id;
+			break;
+	}
 
 	if(slider)
 	{

+ 2 - 10
config/creatures.json

@@ -428,11 +428,7 @@
 				"level": 7,
 				"name": [ "LesserTitan" ],
 				"faction": 2,
-				"ability_add": [ [ "SPELL_IMMUNITY", 0, 62, 0 ],			//giants are immune to mind spells (blind)
-							   	 [ "SPELL_IMMUNITY", 0, 61, 0 ],			//giants are immune to mind spells (forgetfulness)
-								 [ "SPELL_IMMUNITY", 0, 60, 0 ],			//giants are immune to mind spells (hypnotize)
-								 [ "SPELL_IMMUNITY", 0, 59, 0 ],			//giants are immune to mind spells (berserk)
-								 [ "SPELL_IMMUNITY", 0, 50, 0 ] ],			//giants are immune to mind spells (sorrow)
+				"ability_add": [ ["MIND_IMMUNITY", 0, 0, 0] ],			//giants are immune to mind spells
 				"upgrade": 41,
 				"defname": "CLTITA.DEF"
 			},
@@ -442,11 +438,7 @@
 				"level": 7,
 				"name": [ "GreaterTitan" ],
 				"faction": 2,
-				"ability_add": [ [ "SPELL_IMMUNITY", 0, 62, 0 ],			//titans are immune to mind spells (blind)
-							   	 [ "SPELL_IMMUNITY", 0, 61, 0 ],			//titans are immune to mind spells (forgetfulness)
-								 [ "SPELL_IMMUNITY", 0, 60, 0 ],			//titans are immune to mind spells (hypnotize)
-								 [ "SPELL_IMMUNITY", 0, 59, 0 ],			//titans are immune to mind spells (berserk)
-								 [ "SPELL_IMMUNITY", 0, 50, 0 ],			//titans are immune to mind spells (sorrow)
+				"ability_add": [ ["MIND_IMMUNITY", 0, 0, 0],			//Titans are immune to mind spells
 								 [ "HATE", 50, 83, 0 ] ],					//titans hate black dragons
 				"defname": "CGTITA.DEF",
 				"projectile_defname": "CPRGTIX.DEF",

+ 2 - 3
lib/CObjectHandler.cpp

@@ -6816,8 +6816,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar
 			if(id1 != 6) //non-gold prices are doubled
 				r /= 2; 
 
-			assert(g >= r); //should we allow artifacts cheaper than unit of resource?
-			val1 = (g / r) + 0.5;
+			val1 = std::max(1, (int)((g / r) + 0.5)); //don't sell arts for less than 1 resource
 			val2 = 1;
 		}
 		break;
@@ -6831,7 +6830,7 @@ bool IMarket::getOffer(int id1, int id2, int &val1, int &val2, EMarketMode::EMar
 // 				r /= 2; 
 
 			val1 = 1;
-			val2 = (r / g) + 0.5;
+			val2 = std::max(1, (int)((r / g) + 0.5)); //at least one resource is given in return
 		}
 		break;
 	case EMarketMode::CREATURE_EXP: