Skip to content

Scripts for beginners.

User Avatar
#42
Auto-translated
ggroy
Could anyone suggest a script that, upon entering a region, moves a hero (any hero) to another region (or simply to a specified cell)? I need help.

Added 48 minutes later
And another scripting question. I want a script for a quest where the main goal is: Find and bring an artifact to a specified creature. (BUT THE QUEST SHOULD BE A PRIMARY ONE). Please help. I will be eternally grateful.
1)
function teleport1(hero)
SetObjectPosition(hero, x, y, floor) -- replace x, y, floor with coordinates
end

Trigger(REGION_ENTER_AND_STOP_TRIGGER, 'region', "teleport1")
2) Create a quest in the map properties tree, make it a primary quest, type - MANUAL, IsInitiallyActive and IsInitiallyVisible = false.


function objective_1(hero)
local player = GetObjectOwner(hero)
if GetObjectiveState("quest_name", player) == OBJECTIVE_UNKNOWN then
SetObjectiveState("quest_name", OBJECTIVE_ACTIVE, player)
elseif GetObjectiveState("quest_name", player) == OBJECTIVE_ACTIVE and HasArtefact(hero, artefact_number) then
SetObjectiveState("quest_name", OBJECTIVE_COMPLETED, player)
RemoveArtefact(hero, artefact_number)
end
end

SetObjectEnabled("creature_name", nil)
Trigger(OBJECT_TOUCH_TRIGGER, "creature_name", "objective_1")
Карты для Героев Меча и Магии 5
Одиночные: Завеса срывается, Посол, Последний рывок, Эхо Пустоты
Кампания: Империя Единорога

Существа NCF
Орден Порядка: 1
Нейтралы: 1 2 3 4