Skip to content

Help with Specialization.

#1
Auto-translated

Hello, I'm learning how to create specializations in the NHF mod. Currently, I'm working on one for the infamous King Nicolas (the living one), but I'm having trouble getting it to work.

Idea: All neutral creatures of the Order faction join the hero. Basically, it's like the Marshal's ability, but for humans, without the level restriction. I'd be happy if you could help me (and make it work).

The script so far:

NHF_Nicolas_textPath = "/MapObjects/Haven/NewHeroes/Nicolas/"

function error_NHF_Nicolas_F()
    print("Error: NHF_Nicolas")
end

function Nicolas_HavenJoinTrigger(hero, monster)
    if hero == "Nicolas" or hero == "NicolasNHF" then
        if GetObjectFaction(monster) == 0 then
            SetMonsterCourageAndMood(monster, 0, MONSTER_COURAGE_ALWAYS_JOIN, MONSTER_MOOD_FRIENDLY)
        end
        MakeHeroInteractWithObject(hero, monster)
    else
        SetMonsterCourageAndMood(monster, 0, MONSTER_COURAGE_ALWAYS_FIGHT, MONSTER_MOOD_HOSTILE)
        MakeHeroInteractWithObject(hero, monster)
    end
end

function Init_Nicolas_Haven_Join()
    errorHook(error_NHF_Nicolas_F)
    local monsters = GetObjectNamesByType("MONSTER")
    for i, name in monsters do
        if GetObjectFaction(name) == 0 then
            Trigger(OBJECT_TOUCH_TRIGGER, name, "Nicolas_HavenJoinTrigger")
        end
    end
end
AddEvent(map_loading_events, "Init_Nicolas_Haven_Join_Event", Init_Nicolas_Haven_Join)