Posts from How can I prevent monsters from being attacked in scripts?
You can attach a trigger to a monster, and disable the monster itself as an object.
In that case, will it be possible to interact with it?
Using a trigger.
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
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 different 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 creatures-NPCs on the map
-- npc – the name of the monster 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 not be passed
function SetNpcFunc(npc, func, name)
-- disabling the standard touch trigger of the monster (battle)
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 your own 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 a new name is given
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
Thank you very much, this is very useful information.
You can assign a trigger to a monster, and disable the monster itself as an object.
Added 5 minutes later
From the manual in my signature:
How to perform an action when touching a specific monster?
As a rule, a monster with non-standard behavior should be visually different from a
normal one, so as a bonus to the touch trigger, I add changing the cursor from the
standard sword to a peaceful horse, removing the monster's "skirt", and changing its
name:-- setting up creatures-NPCs on the map
-- npc – the name of the monster 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 your own 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('SCRIPTED_MONSTER_NAME');
-- a touch trigger is assigned to the monster, the name remains the same
SetNpcFunc('SCRIPTED_MONSTER_NAME', 'NpcTouch');
-- a touch trigger is assigned to the monster and it is given a new name
SetNpcFunc('SCRIPTED_MONSTER_NAME', 'NpcTouch',
'FILE_NAME_WITH_NAME');
-- monster touch handler
-- hero – the scripted name of the hero who touched the NPC monster
-- npc – the scripted name of the monster that was touched
function NpcTouch(hero, npc)
YOUR CODE
end
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________
Comrade Jack_of_Shadows seems to have explained everything very clearly. What else can I clarify for you if there's a comment for each line? The way the question is phrased is also strange: "Explain what those letters are." Either write what specifically is unclear in the code, or it will seem like you don't understand Russian.
I apologize, but I don't know what a Lua Code Sample is and where to modify it. I've searched online, but I still don't understand. If you know, please answer: 3
P.S. I don't understand how you couldn't find it on Google. The first few pages contain Ogoi's guide to scripts and Remix's videos.
_________________
Группа картостроителей
Там ответы на вопросы, руководства, гайды и прочее
Discord-сервер "Герои 5: S.T.A.L.K.E.R"
Сервер по модификации "Герои 5: S.T.A.L.K.E.R"
_________________