I don't quite understand this part -
for i=0,6 do
local type, num = GetObjectArmySlotCreature("ritual", i)
if (type >= 30 and type <= 42 and mod(type, 2) == 0) or (type >= 152 and type <= 158) then
startThread(NecroRitual)
SetObjectOwner("ritual", PLAYER_2)
end
end.
and then in the ritual function -
for i=0,6 do
local type, num = GetObjectArmySlotCreature("ritual", i)
if GetObjectArmySlotCreature("ritual", i) == 30 then
RemoveObjectCreatures('ritual', type, num, i) ...
Why are you setting the hero as the owner for each slot? Ideally, this could be done outside the loop. And why are you starting a new thread for each slot? I haven't run the script, but it looks like you're starting 2 threads for two slots that run in parallel (sort of), and when the processing of the second cycle in the ritual function goes through all the slots again, the first slot hasn't been cleared yet (by the first thread). It seems that if you remove the loop in the function or remove the duplicated threads, everything should work.
Like this:
MakeHeroInteractWithObject(hero, "ritual")
sleep(10)
startThread(NecroRitual)
SetObjectOwner("ritual", PLAYER_2)
local x,y = GetObjectPosition(Hero) ...
Also, this is purely aesthetic, but since you're taking the hero's name from the function, why are you writing "Hafad" in other places?
Added 44 seconds ago
Right now, I'm tinkering with the Redhaven script for turning ordinary people into green ones. This is quite a challenge...