Posts from Scripts
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?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
Added 1 hour 24 minutes ago
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, named after each number? Can I get by with one progress file with a <changing variable>?
__________________________________
nginx/0.8.54
"Notes collected" < value=zapiski > , it won't help, because I'm not calling this record through a flying sign, but through SetObjectiveProgress... And there's nowhere to insert the magic line {zapiski=zapiski}. I know I'm writing confusingly, but what can I do =).
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>?
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
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.
Damn, that's a shame. Is it really impossible to influence the quest using scripts? Maybe at least its description or title? I saw somewhere that it's possible to change the hero's description, although, with my knowledge of English, I might have translated it incorrectly.
I actually thought it wouldn't be that difficult... Too bad. Okay, I'll go do 100 progress quests. =)
by the way, how do you prevent multiple fly signs from overlapping each other?
Added 6 minutes later
[/U]regarding the developers - I'll take a look now. Yesterday, on RedHeavenHero's advice, I found a great script there to determine the number of killed creatures. Most likely, this function still affects the quest, because there were several variables, such as assasins_dead, which then didn't appear anywhere else. I suspect that they "appeared" not in the script, but in the quest progress description. In any case, thank you for the advice.
Added 33 minutes later
no, I didn't find any progress update anywhere. Even in the quest for 1000 heads =)
by the way, how do you prevent multiple fly signs from overlapping each other?
Add pauses between them.
__________________________________
nginx/0.8.54
Added 15 minutes ago
here's another question:
I want to reset a hero's mana. I'm writing this:
ChangeHeroStat ('Berein' , 8 , GetHeroStat ('Berein' , 8) - 1000)
1)
ChangeHeroStat ('Berein' , 8 , 0) -- doesn't work
2) and how do I reduce a hero's mana by 10?
ChangeHeroStat ('Berein' , 8 , GetHeroStat ('Berein' , 8) - 10) -- doesn't work
ChangeHeroStat('Berein', 8, -GetHeroStat('Berein', 8)) -- all
ChangeHeroStat('Berein', 8, -10) -- ten
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
By the way, I've made some changes to the campaign function that recalculates the number of defeated enemies. But now it works strangely. Can you tell me what's wrong?
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;
--------