• 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!

OTClient affect item or creature

Michy

Member
Joined
May 20, 2010
Messages
105
Reaction score
6
Hello guys i want know if is possible to affect directly from OTClient to an ITEM or CREATURE ID, for example an TREE with client id 699 having a shader effect directly only in his ID.

If anyone know anything about this please reply me, thanks in advance.
 
Any example of this or this need to source editing?
 
C++:
if (item->getId() == X)
doSomething;

If you want @Michy to better navigate between source files you should download for example: Sublime Text Editor and in this editor you have option to import whole Sources into one project, after that you can simply press CTRL+SHIFT+F and search for thing that you need in entire imported sources in project.
That's how I search for things. That's a little tip :)
 
C++:
if (item->getId() == X)
doSomething;

If you want @Michy to better navigate between source files you should download for example: Sublime Text Editor and in this editor you have option to import whole Sources into one project, after that you can simply press CTRL+SHIFT+F and search for thing that you need in entire imported sources in project.
That's how I search for things. That's a little tip :)
What now? o_O
How is this post related to this thread?
 
C++:
void Item::setClassId(int id)
{
    m_classId = id;
    if (id == ITEMCLASS_LEGENDARY)
        setShader(g_shaders.getShader("LegendaryShader"), 0, 0);
    else if (id == ITEMCLASS_UNIQUE)
        setShader(g_shaders.getShader("UniqueShader"), 0, 0);
}

This is my script using shaders with items. I don't have any gif right now :/
 
Great guys, really thanks. I wish there was extensive documentation from OTClient. You have to discover things and sometimes it is annoying

@Oskar1121 this works too with particles right?
 
@Oskar1121 this works too with particles right?
It's not as easy as using setShader (this function doesn't exist). You have to bind shader in draw first.

Example with Creature outfit.
creature.h
C++:
#include "shadermanager.h"

PainterShaderProgramPtr m_shader;
void setShader(const std::string& shader) { m_shader = g_shaders.getShader(shader); }
creature.cpp
Inside void Creature::internalDrawOutfit add lines starting with +.
C++:
// continue if we dont have this addon
if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern-1))))
    continue;
auto datType = rawGetThingType();

+ if (m_shader) {
+     m_shader->bind();
+     g_painter->setShaderProgram(m_shader);
+ }
datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, yPattern == 0 ? lightView : nullptr);
+ g_painter->resetShaderProgram();
 
It's not as easy as using setShader (this function doesn't exist). You have to bind shader in draw first.

Example with Creature outfit.
creature.h
C++:
#include "shadermanager.h"

PainterShaderProgramPtr m_shader;
void setShader(const std::string& shader) { m_shader = g_shaders.getShader(shader); }
creature.cpp
Inside void Creature::internalDrawOutfit add lines starting with +.
C++:
// continue if we dont have this addon
if(yPattern > 0 && !(m_outfit.getAddons() & (1 << (yPattern-1))))
    continue;
auto datType = rawGetThingType();

+ if (m_shader) {
+     m_shader->bind();
+     g_painter->setShaderProgram(m_shader);
+ }
datType->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, yPattern == 0 ? lightView : nullptr);
+ g_painter->resetShaderProgram();
Wow, i really appreciate your example, im beginer at c++ so im trying to see examples to continue testing things, again, thanks for the examples
 
Hello guys, i was trying to change this functions mentioned up to use Particle but it wasn't possible is possible to set up particle to target directly Item/Creature?
 
Look, this is my item shader function:
C++:
void Item::draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView, float opacity)
{
    if(m_clientId == 0)
        return;

    // determine animation phase
    int animationPhase = calculateAnimationPhase(animate);

    // determine x,y,z patterns
    int xPattern = 0, yPattern = 0, zPattern = 0;
    calculatePatterns(xPattern, yPattern, zPattern);

    if (g_graphics.getPainterEngine() == g_graphics.Painter_OpenGL2)
    {
        if (m_shader && g_painter->hasShaders() && g_graphics.shouldUseShaders()) {
            m_shader->bind();
            m_shader->setUniformValue(ShaderManager::ITEM_ID_UNIFORM, m_clientId);
            g_painter->setShaderProgram(m_shader);
        }
    }

    rawGetThingType()->draw(dest, scaleFactor, 0, xPattern, yPattern, zPattern, animationPhase, lightView, opacity);
    g_painter->resetShaderProgram();
}
 
Thanks oskar i will try to check as soon of possible really thanks friend
 
Back
Top