Lucck
New Member
- Joined
- Nov 1, 2018
- Messages
- 10
- Reaction score
- 1
This is a mod to change name and life bar position according to direction you're looking:
(used weird positions just to understand whats changing)
mod:
I would like ask if someone could help edit the mod to also can change position of skull or others icons:
Actually the icons already follow the lifebar position, but what im trying is set the position trought the game_creatureinformation.lua file
The second array (its an example):
Would be the icon (like skulls) position.
Could help a loot change the icon position using lua instead changing it here in creature.cpp:
Then you can easy adjust icons position using game_creatureinformation.lua file
Well i know is not a easy thing to do, appreciate any help.
(used weird positions just to understand whats changing)
mod:
creature.h
change:
to:
after:
add:
after:
add:
creature.cpp
change:
to:
after:
add:
luafunctions.cpp
after:
add:
Now go to OTClient modules/ do a new folder with name game_creatureinformation, and create a file with name "game_creatureinformation.otmod".
Now in same folder do a new archive with name game_creatureinformation.lua and add this code:
change:
Code:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
to:
Code:
void Creature::drawInformation(Point& point, bool useGray, const Rect& parentRect, int drawFlags)
after:
Code:
std::string getName() { return m_name; }
add:
Code:
Point getInformationOffset() { return m_informationOffset; }
void setInformationOffset(int x, int y) {
m_informationOffset.x = x;
m_informationOffset.y = y;
}
after:
Code:
Position m_oldPosition;
add:
Code:
Point m_informationOffset;
creature.cpp
change:
Code:
void Creature::drawInformation(const Point& point, bool useGray, const Rect& parentRect, int drawFlags)
to:
Code:
void Creature::drawInformation(Point& point, bool useGray, const Rect& parentRect, int drawFlags)
after:
Code:
if(!useGray)
fillColor = m_informationColor;
add:
Code:
point.x += m_informationOffset.x;
point.y += m_informationOffset.y;
luafunctions.cpp
after:
Code:
g_lua.bindClassMemberFunction<Creature>("jump", &Creature::jump);
add:
Code:
g_lua.bindClassMemberFunction<Creature>("setInformationOffset", &Creature::setInformationOffset);
g_lua.bindClassMemberFunction<Creature>("getInformationOffset", &Creature::getInformationOffset);
Now go to OTClient modules/ do a new folder with name game_creatureinformation, and create a file with name "game_creatureinformation.otmod".
Code:
Module
name: game_creatureinformation
description: Changes the position of the informations point to correctly draw names and creature bars.
author: Snowsz
website: tibiaking.com
autoload: true
reloadable: true
sandboxed: true
version: 1.0
scripts: [ game_creatureinformation ]
@onLoad: init()
@onUnload: terminate()
Now in same folder do a new archive with name game_creatureinformation.lua and add this code:
Code:
--[[
Directions:
North /\
East >
South \/
West <
Structure:
[OutfitID] = {
[Direction] = {x = OFFSETX, y = OFFSETY},
}
]]
--Lista de offsets para cada Outfit.
local OutfitOffsets = {
[143] = { --Outfit do primeiro gif
[North] = {x = -13, y = -8},
[East] = {x = -17, y = -8},
[South] = {x = -13, y = -8},
[West] = {x = -15, y = -8},
},
[160] = { --Outfit de anão com o nome full drogado.
[North] = {x = 0, y = 0},
[East] = {x = 0, y = 0},
[South] = {x = -13, y = -80},
[West] = {x = 0, y = 0},
}
}
local function translateDir(dir)
if dir == NorthEast or dir == SouthEast then
return East
elseif dir == NorthWest or dir == SouthWest then
return West
end
return dir
end
local function getOutfitInformationOffset(outfit, dir)
if OutfitOffsets[outfit] then
return OutfitOffsets[outfit][translateDir(dir)]
end
return {x = 0, y = 0}
end
local function onCreatureAppear(creature)
local Offset = getOutfitInformationOffset(creature:getOutfit().type, creature:getDirection())
creature:setInformationOffset(Offset.x, Offset.y)
end
local function onCreatureDirectionChange(creature, oldDirection, newDirection)
local Offset = getOutfitInformationOffset(creature:getOutfit().type, newDirection)
creature:setInformationOffset(Offset.x, Offset.y)
end
local function onCreatureOutfitChange(creature, newOutfit, oldOutfit)
local Offset = getOutfitInformationOffset(newOutfit.type, creature:getDirection())
creature:setInformationOffset(Offset.x, Offset.y)
end
function init()
connect(LocalPlayer, {onOutfitChange = onCreatureOutfitChange})
connect(Creature, {
onAppear = onCreatureAppear,
onDirectionChange = onCreatureDirectionChange,
onOutfitChange = onCreatureOutfitChange
})
end
function terminate()
disconnect(LocalPlayer, {onOutfitChange = onCreatureOutfitChange})
disconnect(Creature, {
onAppear = onCreatureAppear,
onDirectionChange = onCreatureDirectionChange,
onOutfitChange = onCreatureOutfitChange
})
end
I would like ask if someone could help edit the mod to also can change position of skull or others icons:
Actually the icons already follow the lifebar position, but what im trying is set the position trought the game_creatureinformation.lua file
Code:
--outfit offsets
local OutfitOffsets = {
[143] = {
[North] = {x = -13, y = -8}, {x = -33, y = -30},
[East] = {x = -17, y = -8},
[South] = {x = -13, y = -8},
[West] = {x = -15, y = -8},
},
The second array (its an example):
Code:
{x = -33, y = -30}
Could help a loot change the icon position using lua instead changing it here in creature.cpp:
Code:
Rect skullRect = Rect(backgroundRect.x() + 13.5 + 12, backgroundRect.y() + 5, m_skullTexture->getSize());
Then you can easy adjust icons position using game_creatureinformation.lua file
Well i know is not a easy thing to do, appreciate any help.
Last edited: