• 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 Party Module

Helliot1

Owner of Empire Online
Joined
Jul 26, 2017
Messages
315
Solutions
1
Reaction score
57
Good day, gentlemen. How are you all doing?

I am currently in the process of creating a module to load information about party members such as their name, level, health points, and mana points. However, I am facing some confusion as to how to approach this task. The module is intended to constantly load information about members, both those currently present on the map and those who are away.

I attempted to pass the TFS ID of all party members to the Otclient through the use of opcodes. I attempted to utilize the GetHealthPercent function with the ID obtained, but it did not produce the desired results. It appears that in the Otclient, each creature has a unique ID different from that of TFS and I would need to obtain this ID directly from the Otclient.

Another issue I encountered is that, in the Otclient, it seems that one can only obtain this information if the creature is currently visible on the player's screen. If the player is not on screen, their health will not update in the module. Information such as mana is also not obtainable through the Otclient.

I am uncertain as to which approach would be the best course of action. Should I pass the information through opcodes on a constant basis or should I consider adding this information directly to the Otclient's source code?

I would greatly appreciate any suggestions or advice on how to proceed.

Thank you.
 
It appears that in the Otclient, each creature has a unique ID different from that of TFS
No.

This can be all done without single change in TFS/OTC sources. TFS already has Party events in data/events. Just send join/left opcodes to your module, use onHealthChange and onManaChange to update their life/mana bars, its as easy as it can get.
 
No.

This can be all done without single change in TFS/OTC sources. TFS already has Party events in data/events. Just send join/left opcodes to your module, use onHealthChange and onManaChange to update their life/mana bars, its as easy as it can get.

I am struggling to understand how this can be achieved. Upon searching for "onHealthChange" within the Otclient's source code, I only came across it in the LocalPlayer.cpp file. This led me to believe that this function only retrieves the health of the local player. To obtain the health of other creatures, I would have to rely on the "getHealthPercent" function. But, this is not what I need as it only retrieves the health of creatures that are currently present on the map.


Lua:
getPlayer = g_map.getCreatureById(playerId)
print(getPlayer:getHealthPercent())

Could you show me how this 'onHealthChange' part would look like?

This image is for a better understanding:

module-png.72832
 

Attachments

Its in TFS.
You helped me, now I have a direction of what to do. So in the 'Events' in TS, I create the function there, which sends the data of the party members via opcode, and I receive them on the client, right? I have a question, sending opcodes constantly, doesn't it make the server slow?

Thank you @oen432!!
 
What do you think TFS is doing by default?
I don't have much knowledge.

I was studying a bit more about it recently and managed to understand everything, but there's one thing that isn't working, the onManaChange function. It doesn't execute when my character uses any kind of magic, whether it's attack magic, healing magic, or support magic. I'm using OTX3.

I believe that all of my scripts are correct.

events.xml
XML:
    <event class="Party" method="onJoin" enabled="1" />
    <event class="Party" method="onLeave" enabled="1" />

events/party.lua
Lua:
function Party:onJoin(player)
    player:registerEvent("onPartyHealthChange")
    player:registerEvent("onPartyManaChange")
    return true
end

function Party:onLeave(player)
    player:unregisterEvent("onPartyHealthChange")
    player:unregisterEvent("onPartyManaChange")
    return true
end

creaturescripts.xml
XML:
    <event type="healthchange" name="onPartyHealthChange" script="onPartyChange.lua" />
    <event type="manachange" name="onPartyManaChange" script="onPartyChange.lua" />

onPartyChange.lua
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print(creature:getHealth())
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print(creature:getMana())
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

I have tested this in every way, onHealthChange is executing correctly but this does not occur with onManaChange, when I use any magic the onManaChange trigger does not fire. It doesn't even print "print(creature:getMana())".

Can you tell me what's wrong with it? Thanks.
 
I don't have much knowledge.

I was studying a bit more about it recently and managed to understand everything, but there's one thing that isn't working, the onManaChange function. It doesn't execute when my character uses any kind of magic, whether it's attack magic, healing magic, or support magic. I'm using OTX3.

I believe that all of my scripts are correct.

events.xml
XML:
    <event class="Party" method="onJoin" enabled="1" />
    <event class="Party" method="onLeave" enabled="1" />

events/party.lua
Lua:
function Party:onJoin(player)
    player:registerEvent("onPartyHealthChange")
    player:registerEvent("onPartyManaChange")
    return true
end

function Party:onLeave(player)
    player:unregisterEvent("onPartyHealthChange")
    player:unregisterEvent("onPartyManaChange")
    return true
end

creaturescripts.xml
XML:
    <event type="healthchange" name="onPartyHealthChange" script="onPartyChange.lua" />
    <event type="manachange" name="onPartyManaChange" script="onPartyChange.lua" />

onPartyChange.lua
Lua:
function onHealthChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print(creature:getHealth())
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

function onManaChange(creature, attacker, primaryDamage, primaryType, secondaryDamage, secondaryType, origin)
    print(creature:getMana())
    return primaryDamage, primaryType, secondaryDamage, secondaryType
end

I have tested this in every way, onHealthChange is executing correctly but this does not occur with onManaChange, when I use any magic the onManaChange trigger does not fire. It doesn't even print "print(creature:getMana())".

Can you tell me what's wrong with it? Thanks.
i guess onManaChange by default trigger only when you get dmg and have mana shield (utamo vita) activated
 
Back
Top