Sanzenkai
Member
- Joined
- Aug 25, 2023
- Messages
- 31
- Reaction score
- 13
Hello, i'm triying to use target with sprites instead of the client itself make the square but every code i find its for OTC 0.6.6, and i'm using the last version released..
If someone is able to help me, thanks.
Mine:
and the one i am trying to replicate and fail
If someone is able to help me, thanks.
Mine:
C++:
void Creature::draw(const Point& dest, bool animate, LightView* lightView)
{
if (!canBeSeen())
return;
const int sprSize = g_sprites.spriteSize();
Point jumpOffset = Point(m_jumpOffset.x, m_jumpOffset.y);
Point creatureCenter = dest - jumpOffset + m_walkOffset - getDisplacement() + Point(sprSize / 2, sprSize / 2);
drawBottomWidgets(creatureCenter, m_walking ? m_walkDirection : m_direction);
Point animationOffset = animate ? m_walkOffset : Point(0, 0);
if (m_showTimedSquare && animate) {
g_drawQueue->addBoundingRect(Rect(dest - jumpOffset + (animationOffset - getDisplacement() + 2 * g_sprites.getOffsetFactor()), Size(sprSize - 4 * g_sprites.getOffsetFactor(), sprSize - 4 * g_sprites.getOffsetFactor())), 2 * g_sprites.getOffsetFactor(), m_timedSquareColor);
}
if (m_showStaticSquare && animate) {
g_drawQueue->addBoundingRect(Rect(dest - jumpOffset + (animationOffset - getDisplacement()), Size(sprSize, sprSize)), 2 * g_sprites.getOffsetFactor(), m_staticSquareColor);
}
if (m_outfit.getCategory() != ThingCategoryCreature)
animationOffset -= getDisplacement();
size_t drawQueueSize = g_drawQueue->size();
m_outfit.draw(dest - jumpOffset + animationOffset, m_walking ? m_walkDirection : m_direction, m_walkAnimationPhase, true, lightView);
if (m_marked) {
g_drawQueue->setMark(drawQueueSize, updatedMarkedColor());
}
drawTopWidgets(creatureCenter, m_walking ? m_walkDirection : m_direction);
Light light = rawGetThingType()->getLight();
if (m_light.intensity != light.intensity || m_light.color != light.color)
light = m_light;
// local player always have a minimum light in complete darkness
if (isLocalPlayer()) {
light.intensity = std::max<uint8>(light.intensity, 2);
if (light.color == 0 || light.color > 215)
light.color = 215;
}
if(lightView)
lightView->addLight(creatureCenter, light);
}
and the one i am trying to replicate and fail
C++:
void Creature::draw(const Point& dest, float scaleFactor, bool animate, LightView *lightView)
{
if(!canBeSeen())
return;
Point animationOffset = animate ? m_walkOffset : Point(0,0);
/*
if(m_showTimedSquare && animate) {
g_painter->setColor(m_timedSquareColor);
g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(28, 28)*scaleFactor), std::max<int>((int)(2*scaleFactor), 1));
g_painter->setColor(Color::white);
}
if(m_showStaticSquare && animate) {
g_painter->setColor(m_staticSquareColor);
g_painter->drawBoundingRect(Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor), std::max<int>((int)(2*scaleFactor), 1));
g_painter->setColor(Color::white);
}
*/
if(m_showTimedSquare && animate) {
/*ImagePtr L3K0Tt = Image::load("data/images/target.png"); //se preferir usar por imagem
TexturePtr L3K0T = TexturePtr(new Texture(L3K0Tt, false));
g_painter->drawTexturedRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(L3K0T->getHeight(), L3K0T->getWidth())*scaleFactor), L3K0T);*/
EffectPtr efeitoL3K0T = EffectPtr(new Effect());
efeitoL3K0T->setId(653); //id da sprite do efeito
g_painter->setColor(m_timedSquareColor);
Rect rect = Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor);
g_painter->drawTexturedRect(rect, efeitoL3K0T->getThingType()->getTexture(0));
g_painter->setColor(Color::white); g_painter->setColor(Color::white); // by L3K0T
g_painter->setOpacity(0.9);
}
if(m_showStaticSquare && animate) {
/*ImagePtr L3K0Tt = Image::load("data/images/target.png"); //se preferir usar por imagem
TexturePtr L3K0T = TexturePtr(new Texture(L3K0Tt, false));
g_painter->drawTexturedRect(Rect(dest + (animationOffset - getDisplacement() + 2)*scaleFactor, Size(L3K0T->getHeight(), L3K0T->getWidth())*scaleFactor), L3K0T);*/
EffectPtr efeitoL3K0T = EffectPtr(new Effect());
efeitoL3K0T->setId(653); //id da sprite do efeito
g_painter->setColor(m_staticSquareColor);
Rect rect = Rect(dest + (animationOffset - getDisplacement())*scaleFactor, Size(Otc::TILE_PIXELS, Otc::TILE_PIXELS)*scaleFactor);
g_painter->drawTexturedRect(rect, efeitoL3K0T->getThingType()->getTexture(0));
g_painter->setColor(Color::white); //1 para não piscar e fixar no vermelho
}
internalDrawOutfit(dest + animationOffset * scaleFactor, scaleFactor, animate, animate, m_direction);
m_footStepDrawn = true;
if(lightView) {
Light light = rawGetThingType()->getLight();
if(m_light.intensity != light.intensity || m_light.color != light.color)
light = m_light;
// local player always have a minimum light in complete darkness
if(isLocalPlayer() && (g_map.getLight().intensity < 64 || m_position.z > Otc::SEA_FLOOR)) {
light.intensity = std::max<uint8>(light.intensity, 3);
if(light.color == 0 || light.color > 215)
light.color = 215;
}
if(light.intensity > 0)
lightView->addLightSource(dest + (animationOffset + Point(16,16)) * scaleFactor, scaleFactor, light);
}
}
Last edited: