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

help weapons

Mateus Robeerto

Legendary OT User
Joined
Jun 5, 2016
Messages
1,747
Solutions
92
Reaction score
1,262
Location
ლ(ಠ益ಠლ)
can someone convert to tfs 1.5? I'm using t.2 working ok, I can't do everything, but very difficult

LUA:
local combat1 = createCombatObject()
setCombatParam(combat1, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat1, COMBAT_PARAM_DISTANCEEFFECT, 35)
function onGetFormulaValues(cid, level, maglevel)
skill = getPlayerSkill(cid,4)
level = getPlayerLevel(cid)
min = -((skill*37)+level*5+maglevel*3)
max = -((skill*38)+level*6+maglevel*3)
return min, max
end

setCombatCallback(combat1, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = createCombatObject()
setCombatParam(combat2, COMBAT_PARAM_EFFECT, 126)
setCombatParam(combat2, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat2, COMBAT_PARAM_DISTANCEEFFECT, 35)
function onGetFormulaValues(cid, level, maglevel)
skill = getPlayerSkill(cid,4)
level = getPlayerLevel(cid)
min = -((skill*44)+level*7+maglevel*4)
max = -((skill*44)+level*8+maglevel*4)
return min, max
end

setCombatCallback(combat2, CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local condition = createConditionObject(CONDITION_PARALYZE)
setConditionParam(condition, CONDITION_PARAM_TICKS, 2000)
setConditionFormula(condition, -0.9, 0, -0.9, 0)
setCombatCondition(combat2, condition)

setCombatCondition(combat2, condition)

local hemorragia = createConditionObject(CONDITION_EMO)
setConditionParam(hemorragia, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(hemorragia, 1, 2000, -3000)
addDamageCondition(hemorragia, 1, 2000, -1500)
addDamageCondition(hemorragia, 1, 2000, -1000)

function onUseWeapon(cid, var)

    local function darkness(target)
     if isPlayer(target) == 1 then
     doSendAnimatedText("Weakness!", getPlayerPosition(cid), 35)
             doCreatureSay(target,"That hurts!",16)
        else
     doSendAnimatedText("Weakness!", getPlayerPosition(cid), 35)
                     end
            end

     local target = getCreatureTarget(cid)
     local black =
   { lookType = getCreatureOutfit(target).lookType,
     lookHead = getCreatureOutfit(target).lookHead,
     lookBody = getCreatureOutfit(target).lookBody,
     lookLegs = getCreatureOutfit(target).lookLegs,
     lookFeet = getCreatureOutfit(target).lookFeet,
     lookAddons = getCreatureOutfit(target).lookAddons }
    fala = math.random(10,10)
    rand = math.random(1,1000)
     if(target ~= 0) then
    if rand <= getPlayerSkill(cid,4) then
    if fala == 10 then
     doCreatureSay(cid,"Fell the darkness!",16)
     doSetCreatureOutfit(target, black, 2000)
     addEvent(darkness, 1*500,target)
    doCreatureAddHealth(cid,(getCreatureMaxHealth(cid)/10))
     doPlayerAddMana(cid,(getPlayerMaxMana(cid)/10))
     doSendAnimatedText("Critical!", getPlayerPosition(cid), 129)
        doCombat(cid, combat2, var)
else
    doCreatureAddHealth(cid,(getCreatureMaxHealth(cid)/10))
     doSendAnimatedText("Critical!", getPlayerPosition(cid), 129)
        doCombat(cid, combat2, var)
end
else
        doCombat(cid, combat1, var)
end
end
end
 
Okay I see some issues:
doSendAnimatedText is deprecated so if you're using some downgraded engine you need to write your own implementation for that.
fala is always equal 10 so what's even the point of the logic in else statement.
hemorragia condition is not even used,
what's that CONDITION_EMO?
You're using some custom 126 effect, some custom effect on your client?
It get's target outfit and set's it back to it's outfit - what's the point? (maybe it was meant to set target outfit to attacker outfit or other way)
You're using talkType 15 which I get warning about on OTClient so maybe use TALKTYPE_MONSTER_SAY

LUA:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat1:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)

function onGetFormulaValues(player, level, magicLevel)
    local distance = player:getSkillLevel(SKILL_DISTANCE)
    min = (distance * 37) + level * 5 + magicLevel * 3
    max = (distance * 38) + level * 6 + magicLevel * 3

    return -min, -max
end

combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE) -- repalced as 126 does not exists - some custom effect?
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)

function onGetFormulaValues(player, level, magicLevel)
    local distance = player:getSkillLevel(SKILL_DISTANCE)
    min = (distance * 44) + level * 7 + magicLevel * 4
    max = (distance * 44) + level * 8 + magicLevel * 4

    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 2000)
condition:setFormula(-0.9, 0, -0.9, 0)
combat2:addCondition(condition)

local function darkness(cid)
    local target = Creature(cid)
    if not creature then
        return
    end

    local position = target:getPosition()
    -- doSendAnimatedText("Weakness!", position, 35)
    if creature:isPlayer() then
        target:say("That hurts!", TALKTYPE_MONSTER_SAY)
    end
end

function onUseWeapon(player, variant)
    local targetCreature = player:getTarget()
    if not targetCreature then
        return false
    end

    local rand = math.random(1, 1000)
    local distance = player:getSkillLevel(SKILL_DISTANCE)

    if rand <= distance then
        local position = player:getPosition()
        local outfit = targetCreature:getOutfit()
        local outfitCondition = Condition(CONDITION_OUTFIT)
        outfitCondition:setOutfit(outfit)
        outfitCondition:setTicks(2000)

        player:say("Fell the darkness!", TALKTYPE_MONSTER_SAY)
        targetCreature:addCondition(outfitCondition)

        addEvent(darkness, 500, targetCreature:getId())
        player:addHealth(player:getMaxHealth() / 10)
        player:addMana(player:getMaxMana() / 10)
        --doSendAnimatedText("Critical!", position, 129)

        return combat2:execute(player, variant)
    end

    return combat1:execute(player, variant)
end

luascript.cpp
C++:
registerMethod("Position", "sendAnimatedText", LuaScriptInterface::luaDoSendAnimatedText);

int LuaScriptInterface::luaDoSendAnimatedText(lua_State* L)
{
    // position:sendAnimatedText(text, color)
    uint32_t color = getNumber<uint32_t>(L, 3);
    std::string text = getString(L, 2);
    const Position& position = getPosition(L, 1);
    g_game.addAnimatedText(position, color, text);
    pushBoolean(L, true);
    return 1;
}

game.cpp
C++:
void Game::addAnimatedText(const Position& pos, uint8_t textColor, const std::string& text)
{
    SpectatorVec spectators;
    map.getSpectators(spectators, pos, true, true);
    addAnimatedText(spectators, pos, textColor, text);
}

void Game::addAnimatedText(const SpectatorVec& list, const Position& pos, uint8_t textColor, const std::string& text)
{
    for (Creature* spectator : list) {
        if (Player* tmpPlayer = spectator->getPlayer()) {
            tmpPlayer->sendAnimatedText(pos, textColor, text);
        }
    }
}

player.h
C++:
void sendAnimatedText(const Position& pos, unsigned char color, const std::string& text) const {
    if (client) {
        client->sendAnimatedText(pos, color, text);
    }
}

porotocolgame.cpp
C++:
void ProtocolGame::sendAnimatedText(const Position& pos, uint8_t color, const std::string& text)
{
    if (!canSee(pos)) {
        return;
    }

    NetworkMessage msg;
    msg.addByte(0x84);
    msg.addPosition(pos);
    msg.addByte(color);
    msg.addString(text);
    writeToOutputBuffer(msg);
}
 
Last edited:
Okay I see some issues:
doSendAnimatedText is deprecated so if you're using some downgraded engine you need to write your own implementation for that.
fala is always equal 10 so what's even the point of the logic in else statement.
hemorragia condition is not even used,
what's that CONDITION_EMO?
You're using some custom 126 effect, some custom effect on your client?
It get's target outfit and set's it back to it's outfit - what's the point? (maybe it was meant to set target outfit to attacker outfit or other way)
You're using talkType 15 which I get warning about on OTClient so maybe use TALKTYPE_MONSTER_SAY

LUA:
local combat1 = Combat()
combat1:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat1:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)

function onGetFormulaValues(player, level, magicLevel)
    local distance = player:getSkillLevel(SKILL_DISTANCE)
    min = (distance * 37) + level * 5 + magicLevel * 3
    max = (distance * 38) + level * 6 + magicLevel * 3

    return -min, -max
end

combat1:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local combat2 = Combat()
combat2:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_BLACKSMOKE) -- repalced as 126 does not exists - some custom effect?
combat2:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat2:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SHIVERARROW)

function onGetFormulaValues(player, level, magicLevel)
    local distance = player:getSkillLevel(SKILL_DISTANCE)
    min = (distance * 44) + level * 7 + magicLevel * 4
    max = (distance * 44) + level * 8 + magicLevel * 4

    return -min, -max
end

combat2:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

local condition = Condition(CONDITION_PARALYZE)
condition:setParameter(CONDITION_PARAM_TICKS, 2000)
condition:setFormula(-0.9, 0, -0.9, 0)
combat2:addCondition(condition)

local function darkness(cid)
    local target = Creature(cid)
    if not creature then
        return
    end

    local position = target:getPosition()
    -- doSendAnimatedText("Weakness!", position, 35)
    if creature:isPlayer() then
        target:say("That hurts!", TALKTYPE_MONSTER_SAY)
    end
end

function onUseWeapon(player, variant)
    local targetCreature = player:getTarget()
    if not targetCreature then
        return false
    end

    local rand = math.random(1, 1000)
    local distance = player:getSkillLevel(SKILL_DISTANCE)

    if rand <= distance then
        local position = player:getPosition()
        local outfit = targetCreature:getOutfit()
        local outfitCondition = Condition(CONDITION_OUTFIT)
        outfitCondition:setOutfit(outfit)
        outfitCondition:setTicks(2000)

        player:say("Fell the darkness!", TALKTYPE_MONSTER_SAY)
        targetCreature:addCondition(outfitCondition)

        addEvent(darkness, 500, targetCreature:getId())
        player:addHealth(player:getMaxHealth() / 10)
        player:addMana(player:getMaxMana() / 10)
        --doSendAnimatedText("Critical!", position, 129)

        return combat2:execute(player, variant)
    end

    return combat1:execute(player, variant)
end

luascript.cpp
C++:
registerMethod("Position", "sendAnimatedText", LuaScriptInterface::luaDoSendAnimatedText);

int LuaScriptInterface::luaDoSendAnimatedText(lua_State* L)
{
    // position:sendAnimatedText(text, color)
    uint32_t color = getNumber<uint32_t>(L, 3);
    std::string text = getString(L, 2);
    const Position& position = getPosition(L, 1);
    g_game.addAnimatedText(position, color, text);
    pushBoolean(L, true);
    return 1;
}

game.cpp
C++:
void Game::addAnimatedText(const Position& pos, uint8_t textColor, const std::string& text)
{
    SpectatorVec spectators;
    map.getSpectators(spectators, pos, true, true);
    addAnimatedText(spectators, pos, textColor, text);
}

void Game::addAnimatedText(const SpectatorVec& list, const Position& pos, uint8_t textColor, const std::string& text)
{
    for (Creature* spectator : list) {
        if (Player* tmpPlayer = spectator->getPlayer()) {
            tmpPlayer->sendAnimatedText(pos, textColor, text);
        }
    }
}

player.h
C++:
void sendAnimatedText(const Position& pos, unsigned char color, const std::string& text) const {
    if (client) {
        client->sendAnimatedText(pos, color, text);
    }
}

porotocolgame.cpp
C++:
void ProtocolGame::sendAnimatedText(const Position& pos, uint8_t color, const std::string& text)
{
    if (!canSee(pos)) {
        return;
    }

    NetworkMessage msg;
    msg.addByte(0x84);
    msg.addPosition(pos);
    msg.addByte(color);
    msg.addString(text);
    writeToOutputBuffer(msg);
}
You're using some custom 126 effect, some custom effect on your client?
R: I use effect yes, I put 126 it worked, follow image.. 126 IS CRITICAL ^^
doSendAnimatedText("Critical!", position, 129) << can you add it? I looked at the source and I still don't understand kk, TFS 1.5 DOWNGRACE NEIKRO
BUT YOUR SCRIPT IS WORKING ALL OK
b9b27a39-b085-4261-871c-07e42267c377.png
 
Back
Top