Auto-translated
How can I use a script to check the number of creatures that died in a battle against a specific hero and output the result to a variable?
Whatever
New here? I'm Roha — want a quick tour?
How can I use a script to check the number of creatures that died in a battle with a specific hero and output the result to a variable?
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.SetGameVar('single', '1')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>?
Is it possible to use scripts to block off a part of the map from the player?
Is it possible to build twice in a city in one turn? I.e., is there a way to unlock a city?
Is it possible to track when a hero interacts with a caravan?
Most likely not. At least, I'm not aware of such a possibility.
by the way, how do you prevent multiple fly signs from overlapping each other?
Trigger( COMBAT_RESULTS_TRIGGER, "combat_results" );
combat_result_last = -1;
c = 1
i = 0
function combat_results( c )
local we = -1
if GetSavedCombatArmyPlayer(c,1) == PLAYER_1 then
we = 1
if we == 1 then
if GetSavedCombatArmyHero(c,we) == 'Berein' then
local stackscount = GetSavedCombatArmyCreaturesCount(c,0);
creature,creaturescount,died = GetSavedCombatArmyCreatureInfo(c,0,i);
AddHeroCreatures('Berein' , 29 , died)
end;
end;
end
if GetSavedCombatArmyPlayer(c,0) == PLAYER_1 then
we = 0
end;
combat_result_last = c;
end;
--------