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

Lua How to open Movement through players?

Vladimir Glebov

http://www.zorgania.com
Joined
Mar 25, 2016
Messages
79
Reaction score
15
Location
Russia
Hello im need open Movement through player by player and

how to off get skull when use Avalance runes example.
 
easy!
Code:
onstepin
if getTopCreature next position is player then
teleportTo from position
else
teleportTo to position true
end
return true
end
 
For the area combat spells you can do something like this.
Code:
function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getTopCreature()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end
Like this if a player targets a monster and there is an other player in the area combat, it won't attack the other player so the player won't get a skull while hunting monsters, I assume this is what you ment.
 
Not sure if I understood well this. Does it allow you to walkthrough players? Isn't that already implemented in last TFS version?
However, I was looking for this. I am using older versions where walkthrough didn't exist, but perhaps a script can allow players to walkthrough when they are inside PZ and not walkthrough monsters or walls etc. Is that possible?
 
easy!
Code:
onstepin
if getTopCreature next position is player then
teleportTo from position
else
teleportTo to position true
end
return true
end

to where post it?

For the area combat spells you can do something like this.
Code:
function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getTopCreature()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end
Like this if a player targets a monster and there is an other player in the area combat, it won't attack the other player so the player won't get a skull while hunting monsters, I assume this is what you ment.


Its now hit myself too :D

qdGmXEJXWwY.jpg


Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_AGGRESSIVE, 0)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))


function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getCreatures()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var, isHotkey)
    return combat:execute(creature, var)
end

This now in Ava rune
 
Last edited by a moderator:
Last edited by a moderator:
The code I posted makes it unable to hit a player in the combat area when you target a monster, if you don't target a monster, you can still damage players with area combats.
 
Code:
<?xml version="1.0" encoding="UTF-8"?>
<events>
    <!-- Creature methods -->
    <event class="Creature" method="onChangeOutfit" enabled="0" />
    <event class="Creature" method="onAreaCombat" enabled="0" />
    <event class="Creature" method="onTargetCombat" enabled="0" />

    <!-- Party methods -->
    <event class="Party" method="onJoin" enabled="0" />
    <event class="Party" method="onLeave" enabled="0" />
    <event class="Party" method="onDisband" enabled="0" />

    <!-- Player methods -->
    <event class="Player" method="onBrowseField" enabled="0" />
    <event class="Player" method="onLook" enabled="1" />
    <event class="Player" method="onLookInBattleList" enabled="1" />
    <event class="Player" method="onLookInTrade" enabled="1" />
    <event class="Player" method="onLookInShop" enabled="0" />
    <event class="Player" method="onMoveItem" enabled="0" />
    <event class="Player" method="onMoveCreature" enabled="1" />
    <event class="Player" method="onTurn" enabled="0" />
    <event class="Player" method="onTradeRequest" enabled="0" />
    <event class="Player" method="onTradeAccept" enabled="0" />
    <event class="Player" method="onGainExperience" enabled="1" />
    <event class="Player" method="onLoseExperience" enabled="0" />
    <event class="Player" method="onGainSkillTries" enabled="1" />
</events>

to event

Code:
function Creature:onChangeOutfit(outfit)
    return true
end

function Creature:onAreaCombat(tile, isAggressive)
    return true
end

function Creature:onTargetCombat(target)
    return true
end
to Creature.lua

and its avalance

Code:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_TYPE, COMBAT_ICEDAMAGE)
combat:setParameter(COMBAT_PARAM_EFFECT, CONST_ME_ICEAREA)
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ICE)
combat:setArea(createCombatArea(AREA_CIRCLE3X3))


function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getCreatures()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end

function onGetFormulaValues(player, level, maglevel)
    local min = (level / 5) + (maglevel * 1.2) + 7
    local max = (level / 5) + (maglevel * 2.85) + 16
    return -min, -max
end

combat:setCallback(CALLBACK_PARAM_LEVELMAGICVALUE, "onGetFormulaValues")

function onCastSpell(creature, var, isHotkey)
    return combat:execute(creature, var)
end
 
You have to enable events if you use them.
Code:
<event class="Creature" method="onAreaCombat" enabled="1" />

Change
Code:
function Creature:onAreaCombat(tile, isAggressive)
      return true
end
To
Code:
function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getTopCreature()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end
And remove it from the rune script.
 
You have to enable events if you use them.
Code:
<event class="Creature" method="onAreaCombat" enabled="1" />

Change
Code:
function Creature:onAreaCombat(tile, isAggressive)
      return true
end
To
Code:
function Creature:onAreaCombat(tile, isAggressive)
     local target = self:getTarget()
     if target and target:isMonster() then
         local c = tile:getTopCreature()
         if c and c:isPlayer() then
             return RETURNVALUE_NOTPOSSIBLE
         end
     end
     return true
end
And remove it from the rune script.


Now work Thx, but im can off its full?

ppl wont take skull :/
 
You can remove the target check.
Code:
local target = self:getTarget()
if target and target:isMonster() then

end
But then you won't be able to use it on players at all.
 
Back
Top