• There is NO official Otland's Discord server and NO official Otland's server list. The Otland's Staff does not manage any Discord server or server list. Moderators or administrator of any Discord server or server lists have NO connection to the Otland's Staff. Do not get scammed!

shaders do not appear on monsters

poncex

Member
Joined
Nov 11, 2012
Messages
60
Reaction score
10
Hi everyone, I followed this tutorial:


to be able to add wings, shaders, etc. to my server, but when I try to add shaders to the monsters, nothing happens. It lets me add them to the NPCs and players, but not to the monsters.

Could someone help me? I've tried modifying the monsters.cpp file, even trying to follow the example of npc.cpp to see if it solves anything, but still nothing happens.
 
Please post the solution so others know
No :v
Post automatically merged:

The solution isn't difficult. The problem, at least for me, is that it doesn't detect shader names, at least for Monsters (unlike NPCs, where you can add the shader name to their respective XML files and it works correctly). I just had to change it so that instead of detecting by name, it detects by shader ID (this is shown in shaders.xml). When I get home from work, I'll post the solution so it's easier to understand.
 
Last edited:
Care to share it? I cant even add it to npcs with shader=”shadername here”, followed same commit and it works on players, but no shaders work on npc or monsters.

Thanks!
Z
 
Hello everyone,

I've added support for setting shader IDs via XML for both monsters and NPCs. This allows you to define the shader directly in their XML files using a new attribute.

Example:
<look ... shader="1" />
Just set the shader attribute and it works for both monsters and NPCs.

This requires source changes.
I’ve already committed them, so just update your source from the branch and it’ll work.
Here’s the commit:
shader
 
Hello everyone,

I've added support for setting shader IDs via XML for both monsters and NPCs. This allows you to define the shader directly in their XML files using a new attribute.

Example:
<look ... shader="1" />
Just set the shader attribute and it works for both monsters and NPCs.

This requires source changes.
I’ve already committed them, so just update your source from the branch and it’ll work.
Here’s the commit:
shader

Great work as always Mateus! Champ :)

I have one small thing, when I import my NPC's with shaders into my mapeditor, and save them on the map --> after starting server with the new map including the shader-NPCs, they spawn without shaders!

Ideas on how to fix? Whats the point of having NPCs with shaders if i have to spawn them manually on the server after each server save? :D
 
Hello everyone,

I've added support for setting shader IDs via XML for both monsters and NPCs. This allows you to define the shader directly in their XML files using a new attribute.

Example:
<look ... shader="1" />
Just set the shader attribute and it works for both monsters and NPCs.

This requires source changes.
I’ve already committed them, so just update your source from the branch and it’ll work.
Here’s the commit:
shader

Great work as always Mateus! Champ :)

I have one small thing, when I import my NPC's with shaders into my mapeditor, and save them on the map --> after starting server with the new map including the shader-NPCs, they spawn without shaders!

Ideas on how to fix? Whats the point of having NPCs with shaders if i have to spawn them manually on the server after each server save? :D

Great work as always Mateus! Champ :)

I have one small thing, when I import my NPC's with shaders into my mapeditor, and save them on the map --> after starting server with the new map including the shader-NPCs, they spawn without shaders!

Ideas on how to fix? Whats the point of having NPCs with shaders if i have to spawn them manually on the server after each server save? :D


I tested this using the Xodet NPC (TFS 1.4.2), and everything seems to work.
The NPC now spawns with the correct shader (in this case shader = 9) right on server startup, you dont have to summon them,
Code made in xodet.lua

LUA:
local keywordHandler = KeywordHandler:new()
local npcHandler = NpcHandler:new(keywordHandler)
NpcSystem.parseParameters(npcHandler)
function onCreatureAppear(cid)            npcHandler:onCreatureAppear(cid)            end
function onCreatureDisappear(cid)        npcHandler:onCreatureDisappear(cid)            end
function onCreatureSay(cid, type, msg)    npcHandler:onCreatureSay(cid, type, msg)    end
function onThink()                        local npc = Npc(getNpcCid())
if npc then local outfit = npc:getOutfit() if outfit.lookShader ~= 9
then outfit.lookShader = 9 npc:setOutfit(outfit)
end end
npcHandler:onThink() end

1752157588189.webp
1752157713948.webp
 
Last edited:
Great work as always Mateus! Champ :)

I have one small thing, when I import my NPC's with shaders into my mapeditor, and save them on the map --> after starting server with the new map including the shader-NPCs, they spawn without shaders!

Ideas on how to fix? Whats the point of having NPCs with shaders if i have to spawn them manually on the server after each server save? :D
It sounds like the issue is happening because your shaders aren't being initialized when the server starts — even though they appear correctly in your map editor. This happens if the server doesn't load the shader definitions before spawning NPCs and monsters.


To fix this, make sure to call g_game.shaders.loadFromXml() in otserv.cpp, right after loading vocations and before loading items or monsters. This guarantees that shaders are loaded first, so any NPCs or monsters saved in your map will have their shaders correctly applied when the server starts — without needing to use /n, /m, or any manual commands.

Example (C++):
C++:
// Load shaders
std::cout << ">> Loading shaders" << std::endl;
if (!g_game.shaders.loadFromXml()) {
    startupErrorMessage("Unable to load shaders!");
    return;
}


Once this is set up and the server is recompiled, shaders will be applied correctly on server start — no hacks, no spawn commands, no extra steps.
 
Last edited:
Make sure to call g_game.shaders.loadFromXml() in otserv.cpp, right after loading vocations and before loading items/monsters. This ensures the server loads the shader list first, so all NPCs and monsters spawn with their assigned shaders automatically when the server starts — no need to use manual commands like /n or /m.


C++:
// Load shaders
std::cout << ">> Loading shaders" << std::endl;
if (!g_game.shaders.loadFromXml()) {
    startupErrorMessage("Unable to load shaders!");
    return;
}


Once added and recompiled, shaders will be correctly applied to NPCs and monsters at spawn time, with no hacks or workarounds required.

Bravo!! Works 100%

Well done Mateus!

//Zeke
 
Back
Top