Skip to content

Posts from Help with Specialization.

No ratings yet — be the first to rate!
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)

User Avatar
Auto-translated
I think you unnecessarily added this line:
else SetMonsterCourageAndMood(monster, 0, MONSTER_COURAGE_ALWAYS_FIGHT, MONSTER_MOOD_HOSTILE)
In your script, there is a mention of the hero "Nicholas," and for him, you are changing the "mood" and "decision" of creatures. If a monster belongs to the Haven faction, its mood and decision are changed. In the next line, you are already stating that they should be aggressive towards this hero and always fight him. Perhaps I am mistaken; I haven't created such specializations.
Some points in your script also seem confusing.
Модификация "New Era": 2%
In reply to temnyrizar
Auto-translated

Diablos_Map
I think you unnecessarily added the following line:
else SetMonsterCourageAndMood(monster, 0, MONSTER_COURAGE_ALWAYS_FIGHT, MONSTER_MOOD_HOSTILE)
In your script, you mention the hero "Nicholas," and for him, you change the "mood" and "decision" of creatures. If a monster belongs to the Haven faction, its mood and decision are changed. In the next line, you already state that they should be aggressive towards this hero and always fight him. Perhaps I'm mistaken; I haven't created such specializations.
Some points in your script also seem confusing.
This line means "if someone other than Nicholas attacks, make the unit hostile." This is to eliminate the possibility of them joining, regardless of which hero is present.

At least, that's what it was intended to do.

In reply to Denkingos
User Avatar
Auto-translated
Denkingos

This line means "if attacked by someone who is NOT Nicolas, make the unit hostile." This is to prevent the possibility of them joining, regardless of which hero is involved.

At least, that's what it was intended to do.



You only mention Nicolas; there is no information about other heroes.
Модификация "New Era": 2%
In reply to Denkingos
Auto-translated
P.S. For the future, don't hesitate to edit the code; I'll be happy if it works, even if it's not my doing, and I hope to learn a lot in the process.

Added 38 minutes later
Diablos_Map


You only mention Nicholas; there's nothing about the other heroes.
I removed the line, but it didn't work.

Statistics

Welcome our newest member: Emil