mirror of
				https://github.com/vcmi/vcmi.git
				synced 2025-10-31 00:07:39 +02:00 
			
		
		
		
	More tweaks.
This commit is contained in:
		| @@ -239,9 +239,11 @@ void CMapGenerator::createConnections() | ||||
| 		int3 guardPos(-1,-1,-1); | ||||
|  | ||||
| 		auto otherZoneTiles = zoneB->getTileInfo(); | ||||
| 		//auto otherZoneCenter = zoneB->getPos(); | ||||
|  | ||||
| 		if (zoneA->getPos().z == zoneB->getPos().z) | ||||
| 		int3 posA = zoneA->getPos(); | ||||
| 		int3 posB = zoneB->getPos(); | ||||
|  | ||||
| 		if (posA.z == posB.z) | ||||
| 		{ | ||||
| 			for (auto tile : tiles) | ||||
| 			{ | ||||
| @@ -255,10 +257,10 @@ void CMapGenerator::createConnections() | ||||
| 				if (guardPos.valid()) | ||||
| 				{ | ||||
| 					setOccupied (guardPos, ETileType::FREE); //just in case monster is too weak to spawn | ||||
| 					zoneA->addMonster (this, guardPos, connection.getGuardStrength()); //TODO: set value according to template | ||||
| 					zoneA->addMonster (this, guardPos, connection.getGuardStrength()); | ||||
| 					//zones can make paths only in their own area | ||||
| 					zoneA->crunchPath (this, guardPos, zoneA->getPos(), zoneA->getId(), zoneA->getFreePaths()); //make connection towards our zone center | ||||
| 					zoneB->crunchPath (this, guardPos, zoneB->getPos(), zoneB->getId(), zoneB->getFreePaths()); //make connection towards other zone center | ||||
| 					zoneA->crunchPath (this, guardPos, posA, zoneA->getId(), zoneA->getFreePaths()); //make connection towards our zone center | ||||
| 					zoneB->crunchPath (this, guardPos, posB, zoneB->getId(), zoneB->getFreePaths()); //make connection towards other zone center | ||||
| 					break; //we're done with this connection | ||||
| 				} | ||||
| 			} | ||||
| @@ -266,8 +268,6 @@ void CMapGenerator::createConnections() | ||||
| 		else //create subterranean gates between two zones | ||||
| 		{	 | ||||
| 			//find point on the path between zones | ||||
| 			int3 posA = zoneA->getPos(); | ||||
| 			int3 posB = zoneB->getPos(); | ||||
| 			float3 offset (posB.x - posA.x, posB.y - posA.y, 0); | ||||
|  | ||||
| 			float distance = posB.dist2d(posA); | ||||
| @@ -280,16 +280,17 @@ void CMapGenerator::createConnections() | ||||
| 			bool stop = false; | ||||
| 			while (!stop) | ||||
| 			{ | ||||
| 				vec += offset; | ||||
| 				vec += offset; //this vector may extend beyond line between zone centers, in case they are directly over each other | ||||
| 				tile = posA + int3(vec.x, vec.y, 0); | ||||
| 				float distanceFromA = posA.dist2d(tile); | ||||
| 				float distanceFromB = posB.dist2d(tile); | ||||
| 				if (distanceFromA >= distance) | ||||
| 					break; | ||||
|  | ||||
| 				if (distanceFromA + distanceFromB > std::max(zoneA->getSize() + zoneB->getSize(), distance)) | ||||
| 					break; //we are too far away to ever connect | ||||
|  | ||||
| 				//if zone is underground, gate must lay withing its (reduced) radius | ||||
| 				if (distanceFromA > 3 && (!posA.z || distanceFromA < zoneA->getSize() - 2) | ||||
| 					&& distanceFromB > 3 && (!posB.z ||distanceFromB < zoneB->getSize() - 2)) | ||||
| 				if (distanceFromA > 3 && (!posA.z || distanceFromA < zoneA->getSize() - 3) && | ||||
| 					distanceFromB > 3 && (!posB.z || distanceFromB < zoneB->getSize() - 3)) | ||||
| 				{ | ||||
| 					otherTile = tile; | ||||
| 					otherTile.z = posB.z; | ||||
|   | ||||
| @@ -948,10 +948,10 @@ void CRmgTemplateZone::createObstacles(CMapGenerator* gen) | ||||
| 		std::vector<int3> rockTiles; | ||||
|  | ||||
| 		for (auto tile : tileinfo) | ||||
| 		{ | ||||
| 			bool placeRock = true; | ||||
| 		{	 | ||||
| 			if (gen->shouldBeBlocked(tile)) | ||||
| 			{ | ||||
| 				bool placeRock = true; | ||||
| 				gen->foreach_neighbour (tile, [gen, &placeRock](int3 &pos) | ||||
| 				{ | ||||
| 					if (!(gen->shouldBeBlocked(pos) || gen->isPossible(pos))) | ||||
|   | ||||
| @@ -102,25 +102,27 @@ void CZonePlacer::placeZones(shared_ptr<CMapGenOptions> mapGenOptions, CRandomGe | ||||
| 			for (auto con : zone.second->getConnections()) | ||||
| 			{ | ||||
| 				auto otherZone = zones[con]; | ||||
| 				float distance = pos.dist2d (otherZone->getCenter()); | ||||
| 				float3 otherZoneCenter = otherZone->getCenter(); | ||||
| 				float distance = pos.dist2d (otherZoneCenter); | ||||
| 				float minDistance = (zone.second->getSize() + otherZone->getSize())/mapSize; //scale down to (0,1) coordinates | ||||
| 				if (distance > minDistance) | ||||
| 				{ | ||||
| 					forceVector += (otherZone->getCenter() - pos) / getDistance(distance); //positive value | ||||
| 					forceVector += (otherZoneCenter - pos) / getDistance(distance); //positive value | ||||
| 				} | ||||
| 			} | ||||
| 			//separate overlaping zones | ||||
| 			for (auto otherZone : zones) | ||||
| 			{ | ||||
| 				float3 otherZoneCenter = otherZone.second->getCenter(); | ||||
| 				//zones on different levels don't push away | ||||
| 				if (zone == otherZone || pos.z != otherZone.second->getCenter().z) | ||||
| 				if (zone == otherZone || pos.z != otherZoneCenter.z) | ||||
| 					continue; | ||||
|  | ||||
| 				float distance = pos.dist2d (otherZone.second->getCenter()); | ||||
| 				float distance = pos.dist2d (otherZoneCenter); | ||||
| 				float minDistance = (zone.second->getSize() + otherZone.second->getSize())/mapSize; | ||||
| 				if (distance < minDistance) | ||||
| 				{ | ||||
| 					forceVector -= (otherZone.second->getCenter() - pos) / getDistance(distance); //negative value | ||||
| 					forceVector -= (otherZoneCenter - pos) / getDistance(distance); //negative value | ||||
| 				} | ||||
| 			} | ||||
|  | ||||
|   | ||||
		Reference in New Issue
	
	Block a user