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

C++ Need include target

jestem pro

That is the question
Joined
Apr 20, 2013
Messages
650
Solutions
14
Reaction score
88
Hello, I try and try, but it's so fucking annoying and hard to understand how it's made.

In this function in spell.cpp:
C++:
bool Spell::playerSpellCheck(Player* player) const
I need to add "target checking". Does the target is monster or not.

C++:
Monster* monster = target->getMonster()
if(monster)
return false;
I know it won't be working, but I can't do.

Tried to add Creature* target to the function, but there are lots of errors in references to others functions.

Any hints?
 
You could do this in the Lua file of your spell script. Or are you going to check in every case?
I know, but in lua it doesn't work as it should.

I will add an option to spells.xml, but I have problem with target.

B.t.w I prefer c++.


Its 8.6 0.3.6 version
 
Fine, is it any attack in any form you want to disable on monsters or what are you trying to achieve? If so, you could probably just edit canDoCombat to exclude monsters completely. There is probably even a flag statement with "cannotattackmonsters" or something similar.
 
This is excatly something else what I want to.

ex. cannotUseOnMonsters="true" put this in spells.xml to a rune.

And then I cannot use that rune on monsters.
 
now only 1, but who knows how many in the future. I think in sources it would be more optimal and convenience
It's simple script for healing:
LUA:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 6)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

function onCastSpell(cid, var)
   return doCombat(cid, combat, var)
end

I tried variantToPosition getCreatureTarget e.t.c but it doesn't work. XDD
 
Code:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HEALING)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_MAGIC_BLUE)
setCombatParam(combat, COMBAT_PARAM_AGGRESSIVE, false)
setCombatParam(combat, COMBAT_PARAM_DISPEL, CONDITION_PARALYZE)
setHealingFormula(combat, COMBAT_FORMULA_LEVELMAGIC, 5, 5, 5, 6)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ENERGYBALL)

function onCastSpell(cid, var)
    local target = getCreatureTarget(cid)
    if isMonster(target) then -- or not isPlayer(target)
        return false
    end
   return doCombat(cid, combat, var)
end

Code:
bool CombatSpell::castSpell(Creature* creature, Creature* target)
//..........................
Player* player = target->getPlayer()
    if (!player) {
        return false;
    }
 
Lua script nor c++ edit dont work.

Fuck its a real shit. This is a fucking joke.

Wanna do something but its so hard to do.....
 
haha there are no errors.

So I compiled this what you wrote. Then I was trying to use a rune on a monster and it works on it BUT IT SHOULDN'T.

Maybe I dont know how it works or use it wrong.

Coz I want to make that the rune cannot be used on monsters.

Generally I dont know why in CombatSpell , but I checked RuneSpell too.
 
haha there are no errors.

So I compiled this what you wrote. Then I was trying to use a rune on a monster and it works on it BUT IT SHOULDN'T.

Maybe I dont know how it works or use it wrong.

Coz I want to make that the rune cannot be used on monsters.

Generally I dont know why in CombatSpell , but I checked RuneSpell too.
For Runes edit
Code:
bool RuneSpell::executeUse(Player* player, Item* item, const PositionEx& posFrom,
    const PositionEx& posTo, bool, uint32_t creatureId)
{
    if(!checkRuneSpell(player, posTo))
        return false;

    // Here if player return false

    bool result = false;
    if(isScripted())
    {
        LuaVariant var;
        if(creatureId && needTarget)
        {
            var.type = VARIANT_NUMBER;
            var.number = creatureId;
        }
        else
        {
            var.type = VARIANT_POSITION;
            var.pos = posTo;
        }

        result = internalCastSpell(player, var);
    }
    else if(function)
        result = function(this, player, item, posFrom, posTo);

    if(result)
    {
        Spell::postSpell(player);
        if(hasCharges && item && g_config.getBool(ConfigManager::REMOVE_RUNE_CHARGES))
            g_game.transformItem(item, item->getID(), std::max((int32_t)0, ((int32_t)item->getItemCount()) - 1));
    }

    return result;
}

Code:
Creature* target;
    if(creatureId >= 0x10000000)
    {
        target = g_game.getCreatureByID(creatureId);
        if (target && target->getPlayer()) {
            return false;
        }
    }
 
Back
Top