mirror of
https://github.com/vcmi/vcmi.git
synced 2025-11-27 22:49:25 +02:00
Fix bug: LandMine is not exploding to enemies. (#630)
* The reason is, the mine has attribute hidden=true; when enemy unit moves, the code in BattleInfo.cpp MoveUnit() (line 817) will update the revealed to true; then in the CGameHandler.cpp handleDamageFromObstacle() (line 4846) is checking , and the condition battleIsObstacleVisibleForSide() will return true, so the effect will not be triggerred. Resolution: 1. Remove the "revealed=true" in moveUnit(), and in handleDamageFromObstacle, remove the "const" restrict for obstacle, and then update revealed to true; 2. After the takeDamage function, add a pack "BattleObstaclesChanged" to update the obstacle to be "revealed=true".
This commit is contained in:
@@ -47,6 +47,7 @@
|
||||
#include "../lib/serializer/CTypeList.h"
|
||||
#include "../lib/serializer/Connection.h"
|
||||
#include "../lib/serializer/Cast.h"
|
||||
#include "../lib/serializer/JsonSerializer.h"
|
||||
|
||||
#ifndef _MSC_VER
|
||||
#include <boost/thread/xtime.hpp>
|
||||
@@ -4857,7 +4858,28 @@ bool CGameHandler::handleDamageFromObstacle(const CStack * curStack, bool stackI
|
||||
battleCast.applyEffects(spellEnv, true);
|
||||
|
||||
if(oneTimeObstacle)
|
||||
{
|
||||
removeObstacle(*obstacle);
|
||||
}
|
||||
else
|
||||
{
|
||||
// For the hidden spell created obstacles, e.g. QuickSand, it should be revealed after taking damage
|
||||
ObstacleChanges changeInfo;
|
||||
changeInfo.id = spellObstacle->uniqueID;
|
||||
changeInfo.operation = ObstacleChanges::EOperation::UPDATE;
|
||||
|
||||
SpellCreatedObstacle changedObstacle;
|
||||
changedObstacle.uniqueID = spellObstacle->uniqueID;
|
||||
changedObstacle.revealed = true;
|
||||
|
||||
changeInfo.data.clear();
|
||||
JsonSerializer ser(nullptr, changeInfo.data);
|
||||
ser.serializeStruct("obstacle", changedObstacle);
|
||||
|
||||
BattleObstaclesChanged bocp;
|
||||
bocp.changes.emplace_back(changeInfo);
|
||||
sendAndApply(&bocp);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user