Does anyone have a suggestion for how to determine via scripts whether the game is running in Multiplayer or Singleplayer mode?
function IsMultiplayer()
local p=0
for i=1,8 do
if IsAIPlayer(i) == 0 then
p=p+1
end
if p > 1 then
return 1
end
end
for i,hero in GetObjectNamesByType('HERO') do
if IsAIPlayer(GetObjectOwner(GetHeroTown(hero) or hero)) == 1 then
SetHeroCombatScript(hero, '/mult.xdb#xpointer(/Script)')
sleep()
local ind = GetLastSavedCombatIndex()
StartCombat(hero,nil,1,1,1)
repeat sleep() until ind ~= GetLastSavedCombatIndex()
ResetHeroCombatScript(hero)
if GetGameVar('single') ~= '1' then return 1 end
break
end
end
return nil
end
/mult.xdb contains a link to the file /mult.lua. Both are located in the root directory, without any intermediate folders.The content of /mult.lua:
SetGameVar('single', '1')Added 23 minutes later
okay, thanks, I'll take a look.
Added 1 hour 24 minutes later
and another question: Is it possible to change the progress of a quest without using a large number of progress texts?
For example, I want to create a 15-turn quest. But it would be enough if its progress simply shows a number, changing from 0 to 15 accordingly. Do I really need to create 15 separate txt files inside the progress folder, with names corresponding to the number? Can I get by with one progress with a <changing variable>?