瀏覽代碼

Remove clone of killed or removed creature. Treat summoned creature as clone when killed.

AlexVinS 9 年之前
父節點
當前提交
d2a5e64542
共有 2 個文件被更改,包括 27 次插入2 次删除
  1. 25 2
      lib/NetPacksLib.cpp
  2. 2 0
      lib/spells/BattleSpellMechanics.cpp

+ 25 - 2
lib/NetPacksLib.cpp

@@ -1307,6 +1307,14 @@ DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs )
 	if(killed())
 	{
 		at->state -= EBattleStackState::ALIVE;
+
+		if(at->cloneID >= 0)
+		{
+			//remove clone as well
+			CStack * clone = gs->curB->getStack(at->cloneID);
+			clone->state.insert(EBattleStackState::DEAD_CLONE);
+			at->cloneID = -1;
+		}
 	}
 	//life drain handling
 	for (auto & elem : healedStacks)
@@ -1329,6 +1337,10 @@ DLL_LINKAGE void BattleStackAttacked::applyGs( CGameState *gs )
 				s->cloneID = -1;
 		}
 	}
+
+	//killed summoned creature should be removed like clone
+	if(killed() && vstd::contains(at->state, EBattleStackState::SUMMONED))
+		at->state.insert(EBattleStackState::DEAD_CLONE);
 }
 
 DLL_LINKAGE void BattleAttack::applyGs( CGameState *gs )
@@ -1612,13 +1624,22 @@ DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs )
 {
 	if(!gs->curB)
 		return;
-	for(ui32 rem_stack : stackIDs)
+
+	while(!stackIDs.empty())
 	{
+		ui32 rem_stack = *stackIDs.begin();
+
 		for(int b=0; b<gs->curB->stacks.size(); ++b) //find it in vector of stacks
 		{
 			if(gs->curB->stacks[b]->ID == rem_stack) //if found
 			{
-				CStack *toRemove = gs->curB->stacks[b];
+				CStack * toRemove = gs->curB->stacks[b];
+
+				//stack may be removed instantly (not being killed first)
+				//handle clone remove also here
+				if(toRemove->cloneID >= 0)
+					stackIDs.insert(toRemove->cloneID);
+
 				gs->curB->stacks.erase(gs->curB->stacks.begin() + b); //remove
 
 				toRemove->detachFromAll();
@@ -1626,6 +1647,8 @@ DLL_LINKAGE void BattleStacksRemoved::applyGs( CGameState *gs )
 				break;
 			}
 		}
+
+		stackIDs.erase(rem_stack);
 	}
 }
 

+ 2 - 0
lib/spells/BattleSpellMechanics.cpp

@@ -586,6 +586,8 @@ void SacrificeMechanics::applyBattleEffects(const SpellCastEnvironment * env, co
 	RisingSpellMechanics::applyBattleEffects(env, parameters, ctx);
 	//it is safe to remove even active stack
 	BattleStacksRemoved bsr;
+	if(victim->cloneID >= 0)
+		bsr.stackIDs.insert(victim->cloneID);
 	bsr.stackIDs.insert(victim->ID);
 	env->sendAndApply(&bsr);
 }