• 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 1.X+ (TFS 1.5) Weapons is not showing distance effect or hit effect with script I am using

JuanRenaldo2

Member
Joined
Feb 25, 2025
Messages
17
Solutions
1
Reaction score
7
Just wondering how to add distance effect and hit effect to my weapons using this script here. the damage is correct but it does not show any to target distance effect or hit effect(Miss, Block, or Hit). I would like to create different weapons with different hit effects and distance effects for ranged weapons.
LUA:
function onUseWeapon(cid, var)
    local target = variantToNumber(var)
    local lvl = getPlayerLevel(cid)
    local skillType = SKILL_DISTANCE
    local skill = getPlayerSkillLevel(cid, skillType)

    local dmgMax = (((1000 * 1) + (skill * 40)) * (1 + (skill / 100))) / 1.4
    local dmgMin = dmgMax / 1.5
    
    local playerTarget = getCreatureTarget(cid)
    local targetPos = getPlayerPosition(playerTarget)
    local fromPos = getPlayerPosition(cid)

    if(target ~= 0) then

        ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, 0)
    end
    return ret
end
 
Solution
Just wondering how to add distance effect and hit effect to my weapons using this script here. the damage is correct but it does not show any to target distance effect or hit effect(Miss, Block, or Hit). I would like to create different weapons with different hit effects and distance effects for ranged weapons.
LUA:
function onUseWeapon(cid, var)
    local target = variantToNumber(var)
    local lvl = getPlayerLevel(cid)
    local skillType = SKILL_DISTANCE
    local skill = getPlayerSkillLevel(cid, skillType)

    local dmgMax = (((1000 * 1) + (skill * 40)) * (1 + (skill / 100))) / 1.4
    local dmgMin = dmgMax / 1.5
   
    local playerTarget = getCreatureTarget(cid)
    local targetPos = getPlayerPosition(playerTarget)
    local...
LUA:
local combat = Combat()
combat:setParameter(COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_ROYALSTAR)

add this at the beggning of your code
 
Just wondering how to add distance effect and hit effect to my weapons using this script here. the damage is correct but it does not show any to target distance effect or hit effect(Miss, Block, or Hit). I would like to create different weapons with different hit effects and distance effects for ranged weapons.
LUA:
function onUseWeapon(cid, var)
    local target = variantToNumber(var)
    local lvl = getPlayerLevel(cid)
    local skillType = SKILL_DISTANCE
    local skill = getPlayerSkillLevel(cid, skillType)

    local dmgMax = (((1000 * 1) + (skill * 40)) * (1 + (skill / 100))) / 1.4
    local dmgMin = dmgMax / 1.5
   
    local playerTarget = getCreatureTarget(cid)
    local targetPos = getPlayerPosition(playerTarget)
    local fromPos = getPlayerPosition(cid)

    if(target ~= 0) then

        ret = doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, 0)
    end
    return ret
end
I was able to fix it by using this code here SOLVED
LUA:
function onUseWeapon(cid, var)
    local playerTarget = getCreatureTarget(cid)
    if not isCreature(playerTarget) then
        return false
    end

    local fromPos = getCreaturePosition(cid)
    local targetPos = getCreaturePosition(playerTarget)
    local skill = getPlayerSkillLevel(cid, SKILL_DISTANCE)

    -- Calculate damage
    local dmgMax = (((1000 * 1) + (skill * 40)) * (1 + (skill / 100))) / 1.4
    local dmgMin = dmgMax / 1.5

    -- Send the projectile effect no matter what
    doSendDistanceShoot(fromPos, targetPos, CONST_ANI_SPEAR)

    -- Manual hit chance simulation
    local hitChance = 90 -- you can adjust or scale this
    local didHit = math.random(1, 100) <= hitChance

    if didHit then
        -- Apply damage
        doTargetCombatHealth(cid, playerTarget, COMBAT_PHYSICALDAMAGE, -dmgMin, -dmgMax, CONST_ME_NONE)
        -- Show hit effect
        doSendMagicEffect(targetPos, CONST_ME_DRAWBLOOD)
    else
        -- Miss: no damage, only visual "miss" effect
        doSendMagicEffect(targetPos, CONST_ME_POFF)
    end

    return true
end
 
Solution
Back
Top