Auto-translated
From the manual in my signature:
How to execute an action when touching a specific monster?
As a rule, it is better to make a monster with non-standard behavior visually distinct from a
normal one, so as a bonus to the touch trigger, I add a change of the cursor from the
standard sword to a peaceful horse, removing the monster's "skirt," and changing its
name:
-- setting up NPC creatures on the map
-- npc – the monster's name assigned in the editor (string)
-- func – the touch handler function (string)
-- name – the name of the file with the creature's name (string)
-- func and name – optional parameters, they can be omitted
function SetNpcFunc(npc, func, name)
-- disabling the standard monster touch trigger (combat)
SetObjectEnabled(npc, nil);
-- setting a peaceful cursor when hovering over the monster
SetDisabledObjectMode(npc, DISABLED_INTERACT);
sleep(1)
-- disabling the "skirt" (faction symbol under the monster)
SetMonsterSelectionType(npc, 0);
-- setting a custom touch trigger (optional parameter)
if (func ~= nil) then
Trigger(OBJECT_TOUCH_TRIGGER, npc, func);
end
-- setting the monster's name (optional parameter)
if (name ~= nil) then
local full_name = GetMapDataPath()..name;
SetMonsterNames(npc, MONSTER_NAME_SINGLE, full_name);
end
end
-- examples of using the function:
-- the monster simply stops reacting to touches
SetNpcFunc(‘SCRIPT_NAME_OF_THE_MONSTER’);
-- a touch trigger is assigned to the monster, the name remains the same
SetNpcFunc(‘SCRIPT_NAME_OF_THE_MONSTER’, ‘NpcTouch’);
-- a touch trigger is assigned to the monster, and it is given a new name
SetNpcFunc(‘SCRIPT_NAME_OF_THE_MONSTER’, ‘NpcTouch’,
‘FILE_NAME_WITH_NAME’);
-- monster touch handler
-- hero – the script name of the hero who touched the NPC monster
-- npc – the script name of the monster that was touched
function NpcTouch(hero, npc)
YOUR CODE
end