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

TFS 0.X Action script is passing through walls

elnelson

Lunaria World Dev
Joined
Jun 20, 2009
Messages
579
Solutions
2
Reaction score
58
Location
México
hey bois, good morning, how can i avoid this script pass through walls?

its a spear active effect for tfs 0.4, but can be abused if player is between walls x.x
XML:
<action itemid="2389" event="script" value="artifacts/spear.lua"/>
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 5, 1000, -5)
setCombatCondition(combat, condition)


function onUse(cid, item, fromPosition, itemEx, toPosition)
--- CONFIG ---
local chance = math.random(0,1)
local levelReq = 1 -- level required to use this effect
local exhStorage = 5452 -- storage for exhaustion between usages
local exhTime = 10 -- time of exhaustion (in seconds)
--- CONFIG ---

  if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid == 2389 or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == 2389 or getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 2389 then
    if getPlayerLevel(cid) >= levelReq then
      local tPos = getCreaturePosition(getCreatureTarget(cid))
      local target = getCreatureTarget(cid)
        if getCreatureTarget(cid) ~= 0 then
          if getDistanceBetween(getCreaturePosition(cid), tPos) <= 3 then
          if not(exhaustion.check(cid,exhStorage)) then
          exhaustion.set(cid, exhStorage, exhTime)
          doSendDistanceShoot(fromPosition, tPos, CONST_ANI_SPEAR)
          doAddCondition(getCreatureTarget(cid), condition)
          doTargetCombatHealth(0, getCreatureTarget(cid), COMBAT_PHYSICALDAMAGE, -5, -25, CONST_ME_NONE)
          doSendAnimatedText(getPlayerPosition(target),"Bleeding", TEXTCOLOR_RED)
          doSendMagicEffect(tPos, CONST_ME_DRAWBLOOD)
          doRemoveItem(item.uid, 1)
          doCreateItem(2389, chance, tPos)
          doCreatureSay(cid, "Toss", 19)
          else
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to wait "..exhaustion.get(cid, exhStorage).." seconds before you can use it again.")
          end
          else 
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need be closer.")  
        end
        else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a target.")  
        end
    else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your need level 20 to use this item.")
    end
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must equip this item first.")
  end
end
 

Attachments

Solution
hey bois, good morning, how can i avoid this script pass through walls?

its a spear active effect for tfs 0.4, but can be abused if player is between walls x.x
XML:
<action itemid="2389" event="script" value="artifacts/spear.lua"/>
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 5...
hey bois, good morning, how can i avoid this script pass through walls?

its a spear active effect for tfs 0.4, but can be abused if player is between walls x.x
XML:
<action itemid="2389" event="script" value="artifacts/spear.lua"/>
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_PHYSICALDAMAGE)
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, true)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_DRAWBLOOD)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_SPEAR)
setCombatFormula(combat, COMBAT_FORMULA_SKILL, 0, 0, 1.0, 0)

local condition = createConditionObject(CONDITION_PHYSICAL)
setConditionParam(condition, CONDITION_PARAM_DELAYED, 1)
addDamageCondition(condition, 5, 1000, -5)
setCombatCondition(combat, condition)


function onUse(cid, item, fromPosition, itemEx, toPosition)
--- CONFIG ---
local chance = math.random(0,1)
local levelReq = 1 -- level required to use this effect
local exhStorage = 5452 -- storage for exhaustion between usages
local exhTime = 10 -- time of exhaustion (in seconds)
--- CONFIG ---

  if getPlayerSlotItem(cid, CONST_SLOT_AMMO).itemid == 2389 or getPlayerSlotItem(cid, CONST_SLOT_RIGHT).itemid == 2389 or getPlayerSlotItem(cid, CONST_SLOT_LEFT).itemid == 2389 then
    if getPlayerLevel(cid) >= levelReq then
      local tPos = getCreaturePosition(getCreatureTarget(cid))
      local target = getCreatureTarget(cid)
        if getCreatureTarget(cid) ~= 0 then
          if getDistanceBetween(getCreaturePosition(cid), tPos) <= 3 then
          if not(exhaustion.check(cid,exhStorage)) then
          exhaustion.set(cid, exhStorage, exhTime)
          doSendDistanceShoot(fromPosition, tPos, CONST_ANI_SPEAR)
          doAddCondition(getCreatureTarget(cid), condition)
          doTargetCombatHealth(0, getCreatureTarget(cid), COMBAT_PHYSICALDAMAGE, -5, -25, CONST_ME_NONE)
          doSendAnimatedText(getPlayerPosition(target),"Bleeding", TEXTCOLOR_RED)
          doSendMagicEffect(tPos, CONST_ME_DRAWBLOOD)
          doRemoveItem(item.uid, 1)
          doCreateItem(2389, chance, tPos)
          doCreatureSay(cid, "Toss", 19)
          else
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need to wait "..exhaustion.get(cid, exhStorage).." seconds before you can use it again.")
          end
          else
          doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need be closer.") 
        end
        else
        doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You need a target.") 
        end
    else
    doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "Your need level 20 to use this item.")
    end
  else
  doPlayerSendTextMessage(cid, MESSAGE_INFO_DESCR, "You must equip this item first.")
  end
end
Lua:
isSightClear(fromPos, toPos, floorCheck)
 
Solution
Lua:
isSightClear(fromPos, toPos, floorCheck)
hey xikini, i added that part in line 32, but seems not working, the spear is still passing through walls

edit: i changed the variables to this isSightClear(fromPosition, tPos, 0) and now working good, thanks xikini :D
 
Last edited:
Soo simple Add this in your combat.ccp:
Search
this
Code:
void AreaCombat::getList(const Position& centerPos, const Position& targetPos, std::forward_list<Tile*>& list) const
{
After ADD

    Tile* tile = g_game.map.getTile(targetPos);
    if (tile->hasProperty(CONST_PROP_BLOCKPROJECTILE)) {
        return;
    }

    if (tile->hasFlag(TILESTATE_FLOORCHANGE)) {
        return;
    }

    if (tile->getTeleportItem()) {
        return;
    }

Later Search this fuction:
     
        for (uint32_t x = 0; x < cols; ++x) {
            if (area->getValue(y, x) != 0) {
                if (g_game.isSightClear(targetPos, tmpPos, true)) {
                 ->   Tile* tile = g_game.map.getTile(tmpPos);
Delet this part:Tile* tile = g_game.map.getTile(tmpPos);
and Add this: tile = g_game.map.getTile(tmpPos);

Later Suck this
 

Similar threads

Back
Top