Posts from Scripts
I need help with this.
I can't understand how to use the "ShowFlyingSign" command correctly:
function offlich()
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "off", nil);
ShowFlyingSign(GetMapDataPath().."offli.txt");
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "off", "offlich");
Since I'm creating a multiplayer map, I want the message to be displayed to the first player. I used this:
function mostFF()
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "most", nil);
MessageBoxForPlayers(PLAYERFLT_1, GetMapDataPath().."most11.txt");
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "most", "mostFF");
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
ShowFlyingSign(messageName, objectName, targetPlayerID = -1, time = 1.0);
I "changed" it, and it stopped complaining, but my version didn't work and looked like this:
ShowFlyingSign("GetMapDataPath().."offli.txt","offlich", "targetPlayerID = -1", "time = 1.5");
ShowFlyingSign({path.."slavescaptured.txt";totalcost=tc},hero,PLAYER_1,5);
ShowFlyingSign(GetMapDataPath().."offlich.txt", off, Player_1, 5);
Original script:
function offlich()
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "off", nil);
ShowFlyingSign(GetMapDataPath().."offlich.txt", off, Player_1, 5);
end;
Trigger(REGION_ENTER_AND_STOP_TRIGGER, "off", "offlich");
I would recommend downloading any story-driven map that is rich in scripts and simply searching for an example of how to use any unclear function within it.
I think I'll look for a map with scripts, but in this situation, I decided not to bother and instead use the template from the "OGO" manual through the "touch object" feature.
function MainKnightSavedHeroReturnWithPlayerThread()
local hero = quest_main_knight.AttackParam('hero');
local start_date = GetDate(ABSOLUTE_DAY);
local move_date = 0;
local curr_date;
local hx_last, hy_last, hf_last = -1, -1, -1;
local hx_curr, hy_curr, hf_curr;
while(1) do
if(IsObjectExists(hero)) then
if(IsObjectExists(player_hero)) then
hx_curr, hy_curr, hf_curr = GetObjectPosition(player_hero);
if((hx_last ~= hx_curr) or (hy_last ~= hy_curr) or (hf_last ~= hf_curr)) then
hx_last, hy_last, hf_last = hx_curr, hy_curr, hf_curr;
MoveHeroRealTime(hero, hx_curr, hy_curr, hf_curr);
end
end
-- movement points are added at the beginning of each turn
curr_date = GetDate(ABSOLUTE_DAY);
if(move_date ~= curr_date) then
move_date = curr_date;
ChangeHeroStat(hero, STAT_MOVE_POINTS, 2500);
sleep(1);
if(IsObjectExists(player_hero)) then
hx_curr, hy_curr, hf_curr = GetObjectPosition(player_hero);
MoveHeroRealTime(hero, hx_curr, hy_curr, hf_curr);
end
end
else
break
end
sleep(5);
end
end
for i=1,100 do
startThread(Func);
end
As a result, multiple instances of the function Func may be launched, even though the previous one might not have finished executing.
NHF 0.90 : NHF - группа в VK
Карты для HeroesV:
Путешествие , Условие крови , Рука судьбы.Часть 1: В поход , Рука судьбы.Часть 2: Отчаянье , Рука судьбы.Часть 3: Восхождение , Стойкость
Абсолютная власть , Иду на Вы! , Корона Ургаша , На задворках
Мир надо уничтожить... Чтобы создать свой...
Is there a script that determines whether a given function is currently running or not? (without using a flag within the function itself)
For example, consider this:As a result, several Func functions may start, even though the previous one might not have finished.
for i=1,100 do
startThread(Func);
end
local threads = {}
local startExec = function(func)
local threads = threads
errorHook(function()
%threads[%func] = nil
end)
threads[func] = 1
func()
threads[func] = nil
end
function startThreadOnce(func)
if not %threads[func] then
startThread(%startExec, func)
end
end
function isFunctionRunning(func)
return %threads[func]
end
In this example, startThreadOnce starts the function only if it is not currently running. isFunctionRunning checks whether the function is currently running.
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
So, please write a 100% working example of the StartCombat script, just one line. I've read so many manuals, but everywhere the description of this script is different, and for some reason none of them work. Thank you in advance.
StartCombat('Brem', nil, 2, CREATURE_PEASANT, 15, CREATURE_ARCHER, 6)
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога
Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4
serovoy, when you create a new hero, you need to assign a unique system name to him, which is then used to reference him in scripts.
upd: although, wait a minute, there's GetPlayerHeroes(player_id), which returns an array of hero names by player ID.