• 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!
  • 2026 staff recruitment is open! Check it out and consider applying!

c/c++ Tibia 7.6 Exp Ring

Devlinn

Member
Joined
Mar 25, 2015
Messages
295
Reaction score
6
hello i can't find exp ring
(exp ring give more experience from monster)
like exp ring = 0.2x on config.lua
time 60minutes etc
 
Last edited:
Code:
local ring = {from = 7697, to = 7708}
local bonus = 2
local rate = getConfigValue ("rateExperience")

function onEquip(cid, item, slot)
    doTransformItem (item.uid, ring.from, 1)
    doPlayerSendTextMessage (cid, 22, 'Now will now earn ' .. bonus .. 'x more experience!')
    doPlayerSetExperienceRate (cid, rate * bonus)
    return TRUE
end


function onDeEquip(cid, item, slot)
    -- just incase :p
    rate = getConfigValue ("rateExperience")
    doTransformItem (item.uid, ring.to, 1)
    doPlayerSendTextMessage (cid, 22 ' you are longer earning.')
    doPlayerSetExperienceRate (cid, rate)
    return TRUE
end
 
Code:
local ring = {from = 7697, to = 7708}
local bonus = 2
local rate = getConfigValue ("rateExperience")

function onEquip(cid, item, slot)
    doTransformItem (item.uid, ring.from, 1)
    doPlayerSendTextMessage (cid, 22, 'Now will now earn ' .. bonus .. 'x more experience!')
    doPlayerSetExperienceRate (cid, rate * bonus)
    return TRUE
end


function onDeEquip(cid, item, slot)
    -- just incase :p
    rate = getConfigValue ("rateExperience")
    doTransformItem (item.uid, ring.to, 1)
    doPlayerSendTextMessage (cid, 22 ' you are longer earning.')
    doPlayerSetExperienceRate (cid, rate)
    return TRUE
end
look here
Screen_Shot_10_29_15_at_12_43_PM.png

i cant use lua....
 
game.cpp
look for :

player->checkRing(thinkTicks);

and on top of it paste:

if(player && player->items[SLOT_RING] && player->items[SLOT_RING]->getID() == ITEM_EXP_RING && !tile->isPz())
{
int exp_ring=g_config.getGlobalNumber("exp_ring", 1)+player->getLevel();
if(g_config.getGlobalNumber("exp_ring", 1) != 0){
player->experience += exp_ring;
player->sendAnimatedText(player->pos, 155, "EXP");
}
}
creature.cpp
look for :

int attackerdamage = getInflicatedDamage(attacker);

and under it paste:
int ring_rate = g_config.getGlobalNumber("exp_ring_rate", 0);
Player* player=dynamic_cast<Player*>(attacker);
Item* ring = player->getItem(SLOT_RING);

then look for :

if (dynamic_cast<Player*>(this))
return gainexperience * g_config.EXP_MUL_PVP;

and again under it paste:

else if(player && ring && ring->getID() == ITEM_EXP_RING)
return gainexperience * g_config.EXP_MUL*ring_rate;

const76.h

look for :
ITEM_STEALTH_RING = 2165,
and under it paste
ITEM_EXP_RING = 2124, // ID OF RING


then open items.xml and add:

<item id="2124" time="500000"/> -- Exp Ring

config.lua

--exp ring amount of exp gained on second
exp_ring= 0
--exp ring rate
exp_ring_rate= 2 how much exp does it increase
 
game.cpp
look for :

player->checkRing(thinkTicks);

and on top of it paste:

if(player && player->items[SLOT_RING] && player->items[SLOT_RING]->getID() == ITEM_EXP_RING && !tile->isPz())
{
int exp_ring=g_config.getGlobalNumber("exp_ring", 1)+player->getLevel();
if(g_config.getGlobalNumber("exp_ring", 1) != 0){
player->experience += exp_ring;
player->sendAnimatedText(player->pos, 155, "EXP");
}
}
creature.cpp
look for :

int attackerdamage = getInflicatedDamage(attacker);

and under it paste:
int ring_rate = g_config.getGlobalNumber("exp_ring_rate", 0);
Player* player=dynamic_cast<Player*>(attacker);
Item* ring = player->getItem(SLOT_RING);

then look for :

if (dynamic_cast<Player*>(this))
return gainexperience * g_config.EXP_MUL_PVP;

and again under it paste:

else if(player && ring && ring->getID() == ITEM_EXP_RING)
return gainexperience * g_config.EXP_MUL*ring_rate;

const76.h

look for :
ITEM_STEALTH_RING = 2165,
and under it paste
ITEM_EXP_RING = 2124, // ID OF RING


then open items.xml and add:

<item id="2124" time="500000"/> -- Exp Ring

config.lua

--exp ring amount of exp gained on second
exp_ring= 0
--exp ring rate
exp_ring_rate= 2 how much exp does it increase
you copy this from tibia.net.pl ..................
and i say this dont WORK.

source/creature.cpp: In member function `virtual exp_t Creature::getGainedExperience(Creature*)':
source/creature.cpp:248: error: redeclaration of `Player*player'
source/creature.cpp:244: error: `Player*player' previously declared here
 
Show me 248 and 244 here best is show whole function between those lines also what distro?
tibiafun engine i edit this post
second
creature.cpp
full
Code:
exp_t Creature::getGainedExperience(Creature* attacker)
{
    int32_t totaldamage = getTotalInflictedDamage();
    int32_t attackerdamage = getInflicatedDamage(attacker);
    exp_t lostexperience = getLostExperience();
    exp_t gainexperience = 0;
    Player* player = dynamic_cast<Player*>(attacker);

    if(attackerdamage > 0 && totaldamage > 0)
    {
        //gainexperience = (int32_t)std::floor(((double)attackerdamage / totaldamage) * lostexperience);
        gainexperience = (exp_t)(attackerdamage * lostexperience / totaldamage);
    }
 
Player* player = dynamic_cast<Player*>(attacker);
this line is there twice try deleting the one you pasted its last from the 3 lines


source/creature.cpp:248: error: redeclaration of `Player*player'

this means that the Player*player was declared twice in the same function.
 
Player* player = dynamic_cast<Player*>(attacker);
this line is there twice try deleting the one you pasted its last from the 3 lines


source/creature.cpp:248: error: redeclaration of `Player*player'

this means that the Player*player was declared twice in the same function.
i know i try this

Code:
exp_t Creature::getGainedExperience(Creature* attacker)
{
    int32_t totaldamage = getTotalInflictedDamage();
    int32_t attackerdamage = getInflicatedDamage(attacker);
int ring_rate = g_config.getGlobalNumber("exp_ring_rate", 0);
    exp_t lostexperience = getLostExperience();
    exp_t gainexperience = 0;
   Player* player=dynamic_cast<Player*>(attacker);
Item* ring = player->getItem(SLOT_RING);

    if(attackerdamage > 0 && totaldamage > 0)
    {
        //gainexperience = (int32_t)std::floor(((double)attackerdamage / totaldamage) * lostexperience);
        gainexperience = (exp_t)(attackerdamage * lostexperience / totaldamage);


    }
but dont work no more experience
 
Player* player=dynamic_cast<Player*>(attacker);
this after
Item* ring = player->getItem(SLOT_RING);
this
also show console if there is any more errors
 
Last edited:
Post your creature.cpp / getGainedExperience Function
clean
PHP:
#ifdef HUCZU_STAGE_EXP
if(g_config.STAGE_EXP)
    {
        int32_t multipiler = 0;
        if(player)
        {
            if(!dynamic_cast<Player*>(this))
                multipiler = g_game.getStageExp(player->getLevel(), false); //brak enfo
            else
                multipiler = g_game.getStageExp(player->getLevel(), true); //enfo

            if(multipiler > 0)
                return gainexperience * multipiler;
        }
    }
    else
    {
        if (dynamic_cast<Player*>(this))
            return gainexperience * g_config.EXP_MUL_PVP;
        else
            return gainexperience * g_config.EXP_MUL;
    }
#endif
    return 0; // dla bezpieczenstwa
}
 
With the Edits.
Code:
#ifdef HUCZU_STAGE_EXP
if(g_config.STAGE_EXP)
    {
        int32_t multipiler = 0;
        if(player)
        {
            if(!dynamic_cast<Player*>(this))
                multipiler = g_game.getStageExp(player->getLevel(), false); //brak enfo
            else
                multipiler = g_game.getStageExp(player->getLevel(), true); //enfo

            if(multipiler > 0)
                return gainexperience * multipiler;
        }
    }
    else
    {
        if (dynamic_cast<Player*>(this))
            return gainexperience * g_config.EXP_MUL_PVP;
else if(player && ring && ring->getID() == ITEM_EXP_RING)
return gainexperience * g_config.EXP_MUL*ring_rate;
        else
            return gainexperience * g_config.EXP_MUL;
    }
#endif
    return 0; // dla bezpieczenstwa
}
 
Sorry for Pain but i need Whole Creature.cpp(with Edits)... all of it
PHP:
#include "definitions.h"

#include <string>
#include <sstream>
#include <algorithm>

#include "game.h"
#include "creature.h"
#include "tile.h"
#include "otsystem.h"
#include "player.h"
#include "luascript.h"

extern LuaScript g_config;

using namespace std;

OTSYS_THREAD_LOCKVAR AutoID::autoIDLock;
uint32_t AutoID::count = 1000;
AutoID::list_type AutoID::list;

extern Game g_game;

Creature::Creature() :
access(0)
{
    direction  = NORTH;
    master = NULL;

    lookhead   = 0;
    lookbody   = 0;
    looklegs   = 0;
    lookfeet   = 0;
    lookmaster = 0;
    looktype   = PLAYER_MALE_1;
    pzLocked = false;

    lookcorpse = ITEM_HUMAN_CORPSE;
  gainHP = 0;
    gainMN = 0;

#ifdef HUCZU_EXHAUSTED
    mmo = 0; //do komend
    lookex= 0; // do look
    antyrainbow = 0; // do outfitow
    antyrainbow2 = 0; // do outfitow
#endif //HUCZU_EXHAUSTED

    health     = 1000;//150;
    healthmax  = 1000;//150;
    lastmove=0;

    inFightTicks = 0;
    inFightTicks = 0;
    manaShieldTicks = 0;
    hasteTicks = 0;
    paralyzeTicks = 0;
    exhaustedTicks  = 0;
    pzLocked = false;
    immunities = 0;
    eventCheck = 0;
    eventCheckAttacking = 0;

    attackedCreature = 0;
    speed = 220;

#ifdef YUR_BOH
    boh = false;
#endif //YUR_BOH
#ifdef YUR_RINGS_AMULETS
    timeRing = false;
#endif //YUR_RINGS_AMULETS

#ifdef HUCZU_SKULLS
    skullType = SKULL_NONE;
#endif //HUCZU_SKULLS

#ifdef YUR_INVISIBLE
    invisibleTicks = 0;
#endif //YUR_INVISIBLE

    bloodcolor = COLOR_RED; //the damage string
    bloodeffect = EFFECT_RED; //the hiteffect
    bloodsplash = SPLASH_RED; //splash on ground
}

Creature::~Creature()
{
    std::list<Creature*>::iterator cit;
    for(cit = summons.begin(); cit != summons.end(); ++cit) {
        (*cit)->setAttackedCreature(NULL);
        (*cit)->setMaster(NULL);
        (*cit)->releaseThing();
    }

    summons.clear();
}

#ifdef YUR_PVP_ARENA
void Creature::drainHealth(int32_t damage, CreatureVector* arenaLosers)
{
    if (arenaLosers && damage >= health)
    {
        health = healthmax;
        arenaLosers->push_back(this);
    }
    else
        health -= min(health, damage);
}
#else
void Creature::drainHealth(int32_t damage)
{
    health -= min(health, damage);
}
#endif //YUR_PVP_ARENA

void Creature::drainMana(int32_t damage)
{
    mana -= min(mana, damage);
}

void Creature::setAttackedCreature(const Creature* creature)
{
    std::list<Creature*>::iterator cit;
    for(cit = summons.begin(); cit != summons.end(); ++cit)
    {
        if((*cit))
            (*cit)->setAttackedCreature(creature);
    }

    if(creature)
    {
        attackedCreature = creature->getID();
    }
    else
        attackedCreature = 0;
}

void Creature::setMaster(Creature* creature)
{
    master = creature;
}

void Creature::addSummon(Creature *creature)
{
    creature->setMaster(this);
    creature->useThing();
    summons.push_back(creature);

}

void Creature::removeSummon(Creature *creature)
{
    std::list<Creature*>::iterator cit = std::find(summons.begin(), summons.end(), creature);
    if(cit != summons.end()) {
        (*cit)->setMaster(NULL);
        (*cit)->releaseThing();
        summons.erase(cit);
    }
}

void Creature::addCondition(const CreatureCondition& condition, bool refresh)
{
    if(condition.getCondition()->attackType == ATTACK_NONE)
        return;

    ConditionVec &condVec = conditions[condition.getCondition()->attackType];

    if(refresh) {
        condVec.clear();
    }

    condVec.push_back(condition);
}

void Creature::addInflictedDamage(Creature* attacker, int32_t damage)
{
    if(damage <= 0)
        return;

    uint32_t id = 0;
    if(attacker)
    {
        id = attacker->getID();
    }

    totaldamagelist[id].push_back(make_pair(OTSYS_TIME(), damage));
}

exp_t Creature::getLostExperience() {
    return 0;
}

int32_t Creature::getInflicatedDamage(uint32_t id)
{
    int32_t ret = 0;
    std::map<int32_t, DamageList >::const_iterator tdIt = totaldamagelist.find(id);
    if(tdIt != totaldamagelist.end()) {
        for(DamageList::const_iterator dlIt = tdIt->second.begin(); dlIt != tdIt->second.end(); ++dlIt) {
            ret += dlIt->second;
        }
    }

    return ret;
}

int32_t Creature::getInflicatedDamage(Creature* attacker)
{
    uint32_t id = 0;
    if(attacker) {
        id = attacker->getID();
    }

    return getInflicatedDamage(id);
}

int32_t Creature::getTotalInflictedDamage()
{
    int32_t ret = 0;
    std::map<int32_t, DamageList >::const_iterator tdIt;
    for(tdIt = totaldamagelist.begin(); tdIt != totaldamagelist.end(); ++tdIt) {
        ret += getInflicatedDamage(tdIt->first);
    }

    return ret;
}

exp_t Creature::getGainedExperience(Creature* attacker)
{
    int32_t totaldamage = getTotalInflictedDamage();
    int32_t attackerdamage = getInflicatedDamage(attacker);
    int32_t ring_rate = g_config.getGlobalNumber("exp_ring_rate", 0);
    exp_t lostexperience = getLostExperience();
    exp_t gainexperience = 0;
    Player* player = dynamic_cast<Player*>(attacker);
    Item* ring = player->getItem(SLOT_RING);

    if(attackerdamage > 0 && totaldamage > 0)
    {
        gainexperience = (exp_t)(attackerdamage * lostexperience / totaldamage);
    }

#ifdef HUCZU_STAGE_EXP
if(g_config.STAGE_EXP)
    {
        int32_t multipiler = 0;
        if(player)
        {
            if(!dynamic_cast<Player*>(this))
                multipiler = g_game.getStageExp(player->getLevel(), false); //brak enfo
            else
                multipiler = g_game.getStageExp(player->getLevel(), true); //enfo

            if(multipiler > 0)
                return gainexperience * multipiler;
        }
    }
    else
    {
        if (dynamic_cast<Player*>(this))
            return gainexperience * g_config.EXP_MUL_PVP;
            else if(player && ring && ring->getID() == ITEM_EXP_RING)
        return gainexperience * g_config.EXP_MUL*ring_rate;
        else
            return gainexperience * g_config.EXP_MUL;
    }
#endif
    return 0; // dla bezpieczenstwa
}

std::vector<int32_t> Creature::getInflicatedDamageCreatureList()
{
    std::vector<int32_t> damagelist;
    std::map<int32_t, DamageList >::const_iterator tdIt;
    for(tdIt = totaldamagelist.begin(); tdIt != totaldamagelist.end(); ++tdIt) {
        damagelist.push_back(tdIt->first);
    }

    return damagelist;
}

bool Creature::canMovedTo(const Tile *tile) const
{
    if(tile)
       {
       return (tile->isBlocking(BLOCK_SOLID, false, false, this) == RET_NOERROR);
    }

    return false;
}

std::string Creature::getDescription(bool self) const
{
    std::stringstream s;
    std::string str;
    s << "a creature.";
    str = s.str();
    return str;
}

int32_t Creature::getStepDuration() const
{
       int32_t duration = 500;
    Tile *tile = g_game.getTile(pos.x, pos.y, pos.z);
    if(tile && tile->ground){
       int32_t groundid = tile->ground->getID();
       uint16_t stepspeed = Item::items[groundid].speed;
        if(stepspeed != 0) {
            duration =  (1000 * stepspeed) / (getSpeed() != 0 ? getSpeed() : 220);
        }
    }
    return duration;
};

int64_t Creature::getSleepTicks() const
{
    int64_t delay = 0;
    int32_t stepDuration = getStepDuration();

    if(lastmove != 0)
    {
        delay = (((int64_t)(lastmove)) + ((int64_t)(stepDuration))) - ((int64_t)(OTSYS_TIME()));
    }

    return delay;
}


#ifdef TR_SUMMONS
bool Creature::isPlayersSummon() const
{
    return master && dynamic_cast<Player*>(master);
}
#endif //TR_SUMMONS


#ifdef YUR_INVISIBLE
bool Creature::checkInvisible(int32_t thinkTicks)
{
    if (invisibleTicks > 0)
    {
        invisibleTicks -= thinkTicks;

        if (invisibleTicks <= 0)
        {
            invisibleTicks = 0;
            return true;    // needs change outfit
        }
    }

    return false;    // outfit stays the same
}
#endif //YUR_INVISIBLE

void Creature::removeCondition(attacktype_t attackType)
{
    if(attackType == ATTACK_NONE)
        return;
    ConditionVec &condVec = conditions[attackType];
    condVec.clear();
}
 

Similar threads

Back
Top