Auto-translated
I did it like this, but the hero still enters the Castle and commits suicide. And there's another problem there... When transforming into a Necropolis, the Halls of Shields somehow become inaccessible, even though the owner hires a caravan from there without any problems. The other buildings work as expected.
```
function CaptureStraker()
if (GetObjectOwner("PlayerTown") == PLAYER_4) then
ChangeHeroStat("Straker", 7, -GetHeroStat('Straker', 7))
Trigger(OBJECT_CAPTURE_TRIGGER, "PlayerTown", nil)
TransformTown("PlayerTown", TOWN_NECROMANCY)
sleep(2)
SetAIPlayerAttractor("PlayerTown", 4, 1)
SetAIPlayerAttractor("DwarfTown", 4, 2)
sleep(2)
ReplaceDwelling("d", TOWN_NECROMANCY)
SetObjectOwner("d", 4)
ReplaceDwelling("dd", TOWN_NECROMANCY)
SetObjectOwner("dd", 4)
ReplaceDwelling("ddd", TOWN_NECROMANCY)
SetObjectOwner("ddd", 4)
ReplaceDwelling("dddd", TOWN_NECROMANCY)
SetObjectOwner("dddd", 4)
AddObjectCreatures("PlayerTown", CREATURE_LICH, 20)
AddObjectCreatures("PlayerTown", CREATURE_BONE_DRAGON, 10)
ChangeHeroStat("Straker", 0, 25000)
end
end