Posts from Scripts for beginners.
I'm trying to create a script that doubles the army size. I borrowed the script from "Random Wars" as a base.
[spoiler=This works, but only for one hero]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = GetPlayerHeroes(5)[0]
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
--local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
I want to implement a scheme with multiple heroes, but I don't know how to write it correctly.
[spoiler=Doesn't work]
function incom()
local day = GetDate(3)
if day == 2 then
local hero = {}
hero[0], hero[1], hero[2], hero[3] = GetPlayerHeroes(5)
for k = 0, 3 do
if IsHeroAlive(hero)
then
local types = {}
types[0], types[1], types[2], types[3], types[4], types[5],types[6] = GetHeroCreaturesTypes(hero)
for i = 0, 6 do
if HasHeroCreature(hero, types)
then
local stack = GetCreatureById(types)
local amount = GetHeroCreatures(hero, types)
AddHeroCreatures(hero, types, amount, i)
end
end
end
end
end
end
Trigger(NEW_DAY_TRIGGER, "incom")
[/spoiler]
The function IsHeroAlive(hero) produces an invalid argument #1, i.e., instead of 'hero', something inedible appears.
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
My deepest respect to you, Most Wise Wizard! Without a ready-made script, I wouldn't have understood anything, as I am uneducated.
And yes, the functions are there, but I have removed (commented out?) the local stack as it is not needed.
Будь яростней пред ночью всех ночей,
Не дай погаснуть свету своему!
Хоть мудрый знает – не осилишь тьму
Во мгле словами не зажжёшь лучей –
Не уходи безропотно во тьму.
In my case, I want to make it so that after 14 days, it becomes possible to build Titans in the Academy, even though creatures of level 7 could not be built before.
P.S. I apologize for my noob question, but I have reviewed all the previous pages and did not find such a question or script.
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
function NewDay()
if GetDate(DAY) == 14 then
UpgradeTownBuilding("Town", TOWN_BUILDING_DWELLING_7, level) --0— not built, 1 — built, 2 — upgraded
end
end
Trigger(NEW_DAY_TRIGGER, "NewDay")
Good day! Could someone suggest a script that, when a Haven town is captured, the town is removed and replaced with a ruined town?
Кампании: "Новый порядок", "Серый Альянс", "Поиски Истины"
Трейлер №2 кампании "Дыхание Пустоты": https://www.youtube.com/watch?v=XkHKXk5BctA&ab_channel=%D0%90ndrei_21
There is a script command RazeTown("script name of the town"). With its help, you can destroy Haven and Dungeon castles by default. For castles of other factions, you need to make some adjustments.
Thank you in advance.
function CaptureTown()
RazeTown('your town name')
end
Trigger(OBJECT_CAPTURE_TRIGGER, 'your town name', 'CaptureTown')It's simple: you assign a script name to the town in the map editor, and then you write something like this function in the script editor.
Кампании: "Новый порядок", "Серый Альянс", "Поиски Истины"
Трейлер №2 кампании "Дыхание Пустоты": https://www.youtube.com/watch?v=XkHKXk5BctA&ab_channel=%D0%90ndrei_21
Ideally, with examples, because I won't understand much without them.
Can someone explain to me how to use the SetObjectiveState script? Many people suggested using it when I asked how to create an object that gives a quest.
Ideally, with examples, because I won't understand much without them.
In simple terms, the script activates a quest, completes/fails it.
SetObjectiveState("prim1", OBJECTIVE_ACTIVE) -- the first parameter is the quest name, the second is the status.
function PRIM3_COMPL()
Trigger(REGION_ENTER_AND_STOP_TRIGGER, '4', nil)
if GetCurrentPlayer()==1 then
SetObjectiveState("prim3", OBJECTIVE_COMPLETED) -- the same, but with a different quest status.
print("32")
end
end
Trigger(REGION_ENTER_AND_STOP_TRIGGER, '4', 'PRIM3_COMPL')
Трава по пояс,
Зайду в траву, как в море босиком...
BlueHeavenHero,
OBJECTIVE_ACTIVE - makes a quest active, meaning it can be completed and will be displayed to the player(s).
OBJECTIVE_COMPLETED - completes a quest.
OBJECTIVE_FAILED - fails a quest.
The OBJECTIVE_UNKNOWN status is also used for various situations, mainly in the GetObjectiveState function, to check if the quest has already been issued, in other words, if it doesn't have one of the previously mentioned statuses.
P.S. I can also add that you can set the "CanUncomplete" property of quests to "true," which will allow you to restart quests, i.e., make completed quests active again.