Skip to content
User Avatar
#4
Auto-translated
1. How do I remove the "circles" around creatures (indicating their race)?
2. How do I make creatures "inactive" so that they cannot be interacted with?
SetObjectEnabled("object name", nil);
SetDisabledObjectMode("object name", DISABLED_INTERACT);
sleep(1)
SetMonsterSelectionType("object name", 0);
3. How do I rename creatures to get the original unit?
SetMonsterNames("object name", MONSTER_NAME_SINGLE, "file name with the new name");

The complete code of my function, which performs all three operations:
-- setting up NPC creatures on the map
function SetNpcFunc(npc, func, name)

-- disable selection and set a peaceful icon on hover
SetObjectEnabled(npc, nil);
SetDisabledObjectMode(npc, DISABLED_INTERACT);
sleep(1)
SetMonsterSelectionType(npc, 0);

-- handler function for clicking - optional parameter
if(func ~= nil) then
Trigger(OBJECT_TOUCH_TRIGGER, npc, func);
end

-- NPC name - optional parameter
if(name ~= nil) then
SetMonsterNames(npc, MONSTER_NAME_SINGLE, name);
end

end
The second parameter is optional; if not passed, nothing will happen when clicking on the creature.
The third parameter is optional; if not passed, the name will remain the default.
Example of use:
SetNpcFunc('foo', 'bar', GetMapDataPath()..'name.txt');

-- handler function for touching creature foo
function bar(hero, obj)
-- ...
end

Statistics

Welcome our newest member: leyu