Explorar o código

Minor changes

nordsoft %!s(int64=2) %!d(string=hai) anos
pai
achega
008db447e7

+ 6 - 0
config/objects/moddables.json

@@ -122,6 +122,8 @@
 				"layer" : "sail",
 				"actualAnimation" : "AB01_.def",
 				"overlayAnimation" : "ABM01_.def",
+				"onboardAssaultAllowed" : true,
+				"onboardVisitAllowed" : true,
 				"flagAnimations" : ["ABF01L", "ABF01G", "ABF01R", "ABF01D", "ABF01B", "ABF01P", "ABF01W", "ABF01K"]
 			},
 			"good" : 
@@ -131,6 +133,8 @@
 				"layer" : "sail",
 				"actualAnimation" : "AB02_.def",
 				"overlayAnimation" : "ABM02_.def",
+				"onboardAssaultAllowed" : true,
+				"onboardVisitAllowed" : true,
 				"flagAnimations" : ["ABF02L", "ABF02G", "ABF02R", "ABF02D", "ABF02B", "ABF02P", "ABF02W", "ABF02K"]
 			},
 			"neutral" : { 
@@ -139,6 +143,8 @@
 				"layer" : "sail",
 				"actualAnimation" : "AB03_.def",
 				"overlayAnimation" : "ABM03_.def",
+				"onboardAssaultAllowed" : true,
+				"onboardVisitAllowed" : true,
 				"flagAnimations" : ["ABF03L", "ABF03G", "ABF03R", "ABF03D", "ABF03B", "ABF03P", "ABF03W", "ABF03K"]
 			},
 		}

+ 2 - 0
lib/mapObjects/CommonConstructors.cpp

@@ -264,6 +264,8 @@ void BoatInstanceConstructor::initTypeData(const JsonNode & input)
 	int pos = vstd::find_pos(NPathfindingLayer::names, input["layer"].String());
 	if(pos != -1)
 		layer = EPathfindingLayer(pos);
+	onboardAssaultAllowed = input["onboardAssaultAllowed"].Bool();
+	onboardVisitAllowed = input["onboardVisitAllowed"].Bool();
 	actualAnimation = input["actualAnimation"].String();
 	overlayAnimation = input["overlayAnimation"].String();
 	for(int i = 0; i < flagAnimations.size() && i < input["flagAnimations"].Vector().size(); ++i)

+ 9 - 0
lib/mapObjects/CommonConstructors.h

@@ -147,6 +147,8 @@ protected:
 	
 	std::vector<Bonus> bonuses;
 	EPathfindingLayer layer;
+	bool onboardAssaultAllowed; //if true, hero can attack units from transport
+	bool onboardVisitAllowed; //if true, hero can visit objects from transport
 	
 	std::string actualAnimation; //for OH3 boats those have actual animations
 	std::string overlayAnimation; //waves animations
@@ -159,6 +161,13 @@ public:
 	template <typename Handler> void serialize(Handler &h, const int version)
 	{
 		h & static_cast<CDefaultObjectTypeHandler<CGBoat>&>(*this);
+		h & layer;
+		h & onboardAssaultAllowed;
+		h & onboardVisitAllowed;
+		h & bonuses;
+		h & actualAnimation;
+		h & overlayAnimation;
+		h & flagAnimations;
 	}
 };
 

+ 4 - 1
lib/mapObjects/MiscObjects.h

@@ -419,7 +419,8 @@ class DLL_LINKAGE CGBoat : public CGObjectInstance, public CBonusSystemNode
 public:
 	ui8 direction;
 	const CGHeroInstance *hero;  //hero on board
-	
+	bool onboardAssaultAllowed; //if true, hero can attack units from transport
+	bool onboardVisitAllowed; //if true, hero can visit objects from transport
 	EPathfindingLayer::EEPathfindingLayer layer;
 	
 	//animation filenames. If empty - animations won't be used
@@ -442,6 +443,8 @@ public:
 		h & direction;
 		h & hero;
 		h & layer;
+		h & onboardAssaultAllowed;
+		h & onboardVisitAllowed;
 		h & actualAnimation;
 		h & overlayAnimation;
 		h & flagAnimations;

+ 13 - 3
server/CGameHandler.cpp

@@ -2364,10 +2364,16 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
 	{
 		for (CGObjectInstance *obj : t.visitableObjects)
 		{
-			if (obj != h  &&  obj->blockVisit  &&  !obj->passableFor(h->tempOwner))
+			if(h->boat && !obj->blockVisit && !h->boat->onboardVisitAllowed)
+				return doMove(TryMoveHero::SUCCESS, this->IGNORE_GUARDS, DONT_VISIT_DEST, REMAINING_ON_TILE);
+			
+			if (obj != h && obj->blockVisit && !obj->passableFor(h->tempOwner))
 			{
-				return doMove(TryMoveHero::BLOCKING_VISIT, this->IGNORE_GUARDS, VISIT_DEST, REMAINING_ON_TILE);
-				//this-> is needed for MVS2010 to recognize scope (?)
+				EVisitDest visitDest = VISIT_DEST;
+				if(h->boat && !h->boat->onboardVisitAllowed)
+					visitDest = DONT_VISIT_DEST;
+				
+				return doMove(TryMoveHero::BLOCKING_VISIT, this->IGNORE_GUARDS, visitDest, REMAINING_ON_TILE);
 			}
 		}
 		return false;
@@ -2405,6 +2411,7 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
 
 		return true;
 	}
+	
 
 	//still here? it is standard movement!
 	{
@@ -2427,6 +2434,9 @@ bool CGameHandler::moveHero(ObjectInstanceID hid, int3 dst, ui8 teleporting, boo
 		}
 		else if (blockingVisit())
 			return true;
+		
+		if(h->boat && !h->boat->onboardAssaultAllowed)
+		   lookForGuards = IGNORE_GUARDS;
 
 		doMove(TryMoveHero::SUCCESS, lookForGuards, visitDest, LEAVING_TILE);
 		return true;