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

Spells Versus Walls

IgoR lYCAN

New Member
Joined
Dec 1, 2018
Messages
169
Reaction score
4
Well.. Wel..

Im using a server based on TFS 1.3

My problem is that :
When You conjure a instant spell, infront of a wall, the spell pass trought it.
Im trying to figure it out how to block the spell to not pass trought the wall.


A video explaining it:

A picture:
1579790219550.png

if there is another wall, it get blocked.

1579790256297.png
 
Ive commented these lines:
C++:
if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) {
    return RETURNVALUE_NOTENOUGHROOM;
}
giphy.gif


Uncomment those lines, see how it goes.
 
Thanks, now I get what your problem is and what you want.
You want so that the part of the area of the spell that doesn't touch something solid(a wall for example), still gets executed.
Now I also understand why you commented out those lines in the sources, but that was a prime example of a Duct tape Fix, while solving the issue it also created further complications.

I think there are 2 possible solutions to this, possibly more:
1. Finding a way inside exori_min.lua to make part of the area ignore walls.
2. Changing how the direction="1" variable in spells.lua works with areas (createCombatArea), either by script or in sources.
Since the way it currently works is that it's checking if something solid is in front of the player and then denies the spell if there is.
You want the walls to continue blocking the way they currently do, so I wouldn't recommend messing with that code anymore.
What you want is for direction to check if there is any part of the spell that is not blocked close to the player, then make it cast it if that is true.

I made this test script to replicate your problem, maybe someone more enlightened can solve this:
test-exori_min.lua
Lua:
local exori_min = {
{1, 3, 1}
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(exori_min))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (skill + attack) * 1
    local max = (skill + attack) * 2
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

spells.lua
XML:
<instant group="attack" spellid="80" name="Test" words="exori min" magiclevel="0" mana="0" premium="0" needweapon="1" direction="1" blockwalls="1" cooldown="2000" groupcooldown="2000" needlearn="0" script="test/test-exori_min.lua" />
I have no idea how blockwalls="1" works, but as far as I could tell, it didn't solve the problem.

I'm quite positive that the issue is in direction="1" because non-directed spells works as you'd want them too, like Berserk for example:
test4.png
I would even say that you might've found yourself a bug in the sources that should be reviewed by the TFS team.


I'll keep trying aswell, but I'm more or less a script kiddie when it comes to C++.
I guarantee you though that someone on this forum can and most likely will solve your problem.
 
Last edited:
Thanks, now I get what your problem is and what you want.
You want so that the part of the area of the spell that doesn't touch something solid(a wall for example), still gets executed.
Now I also understand why you commented out those lines in the sources, but that was a prime example of a Duct tape Fix, while solving the issue it also created further complications.

I think there are 2 possible solutions to this, possibly more:
1. Finding a way inside exori_min.lua to make part of the area ignore walls.
2. Changing how the direction="1" variable in spells.lua works with areas (createCombatArea), either by script or in sources.
Since the way it currently works is that it's checking if something solid is in front of the player and then denies the spell if there is.
You want the walls to continue blocking the way they currently do, so I wouldn't recommend messing with that code anymore.
What you want is for direction to check if there is any part of the spell that is not blocked close to the player, then make it cast it if that is true.

I made this test script to replicate your problem, maybe someone more enlightened can solve this:
test-exori_min.lua
Lua:
local exori_min = {
{1, 3, 1}
}

local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_HITAREA)
combat:setParameter(COMBAT_PARAM_BLOCKARMOR, true)
combat:setParameter(COMBAT_PARAM_USECHARGES, true)
combat:setArea(createCombatArea(exori_min))

function onGetFormulaValues(player, skill, attack, factor)
    local min = (skill + attack) * 1
    local max = (skill + attack) * 2
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_SKILLVALUE, "onGetFormulaValues")

function onCastSpell(creature, variant)
    return combat:execute(creature, variant)
end

spells.lua
XML:
<instant group="attack" spellid="80" name="Test" words="exori min" magiclevel="0" mana="0" premium="0" needweapon="1" direction="1" blockwalls="1" cooldown="2000" groupcooldown="2000" needlearn="0" script="test/test-exori_min.lua" />
I have no idea how blockwalls="1" works, but as far as I could tell, it didn't solve the problem.

I'm quite positive that the issue is in direction="1" because non directed spells works as you'd want them too, like Berserk for example:
View attachment 42557
I would even say that you might've found yourself a bug in the sources that should be reviewed by the TFS team.


I'll keep trying aswell, but I'm more or less a script kiddie when it comes to C++.
I guarantee you though that someone on this forum can and most likely will solve your problem.
If you havefind any solution leave it here please. ! :D
 
spells.cpp change second
var.pos = Spells::getCasterPosition(player, player->getDirection());
to
var.pos = player->getPosition();

u will be able to cast beam spells then
 
Back
Top