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

[weapon]Multitarget wand 'star shoter'

He just attack one monster here. Just I having this problem ?

This happened to someone ? my server is 8.7 tfs 0.4 trunk.r4382, no errors occurred just no atk another monsters.
 
802976260c6b.jpg


2008
 

Attachments

I will fix :)

- - - Updated - - -

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -25, -0.2, -3)

local manaNeededPerTarget = 20
local hitExtraTargets = 3
local hitExtraTargetsInRange = 2

function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z, stackpos = STACKPOS_TOP_CREATURE})
                if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1) then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end
    return creaturesList
end

function onUseWeapon(cid, var)
    local ret = doCombat(cid, combat, var)
    if(ret == LUA_ERROR) then
        return LUA_ERROR
    end
    doPlayerAddManaSpent(cid, manaNeededPerTarget)
    doCreatureAddMana(cid, -manaNeededPerTarget)
    
    local target = variantToNumber(var)
    local hitplayers = 0
    if(target ~= 0) then
        if(isPlayer(target) == TRUE) then
            hitplayers = 1
        end
        local nowHit = 0
        local randomId = 0
        local otherTargets = getCreaturesInRange(getCreaturePosition(target), hitExtraTargetsInRange, hitExtraTargetsInRange, 1, hitplayers)
        if(#otherTargets > 0) then
            for i = 1, hitExtraTargets do
                if(getCreatureMana(cid) > manaNeededPerTarget) then
                    randomId = math.random(1, #otherTargets)
                    nowHit = otherTargets[randomId]
                    if((isCreature(nowHit) == TRUE) and getTilePzInfo(getCreaturePosition(target))) then
                        table.remove(otherTargets, randomId)
                        ret = doCombat(cid, combat, numberToVariant(nowHit))
                        if(ret ~= LUA_ERROR) then
                            doPlayerAddManaSpent(cid, manaNeededPerTarget)
                            doCreatureAddMana(cid, -manaNeededPerTarget)
                        end
                    end
                    if(#otherTargets == 0) then
                        break
                    end
                else
                    break
                end
            end
        end
    end
    return TRUE
end

It is protected so you cant shoot players in depot

player 1 stands outside depot with this wand
player 2 stands outside as an sacrefiece
player 3 stands inside depot

player 1 shoots player 2, and the damage doesnt bumps over to player 3 which is inside depot.
 
Last edited:
I will fix :)

- - - Updated - - -

Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -25, -0.2, -3)

local manaNeededPerTarget = 20
local hitExtraTargets = 3
local hitExtraTargetsInRange = 2

function getCreaturesInRange(position, radiusx, radiusy, showMonsters, showPlayers)
    local creaturesList = {}
    for x = -radiusx, radiusx do
        for y = -radiusy, radiusy do
            if not (x == 0 and y == 0) then
                creature = getTopCreature({x = position.x+x, y = position.y+y, z = position.z, stackpos = STACKPOS_TOP_CREATURE})
                if (creature.type == 1 and showPlayers == 1) or (creature.type == 2 and showMonsters == 1) then
                    table.insert(creaturesList, creature.uid)
                end
            end
        end
    end
    return creaturesList
end

function onUseWeapon(cid, var)
    local ret = doCombat(cid, combat, var)
    if(ret == LUA_ERROR) then
        return LUA_ERROR
    end
    doPlayerAddManaSpent(cid, manaNeededPerTarget)
    doCreatureAddMana(cid, -manaNeededPerTarget)
    
    local target = variantToNumber(var)
    local hitplayers = 0
    if(target ~= 0) then
        if(isPlayer(target) == TRUE) then
            hitplayers = 1
        end
        local nowHit = 0
        local randomId = 0
        local otherTargets = getCreaturesInRange(getCreaturePosition(target), hitExtraTargetsInRange, hitExtraTargetsInRange, 1, hitplayers)
        if(#otherTargets > 0) then
            for i = 1, hitExtraTargets do
                if(getCreatureMana(cid) > manaNeededPerTarget) then
                    randomId = math.random(1, #otherTargets)
                    nowHit = otherTargets[randomId]
                    if((isCreature(nowHit) == TRUE) and getTilePzInfo(getCreaturePosition(target))) then
                        table.remove(otherTargets, randomId)
                        ret = doCombat(cid, combat, numberToVariant(nowHit))
                        if(ret ~= LUA_ERROR) then
                            doPlayerAddManaSpent(cid, manaNeededPerTarget)
                            doCreatureAddMana(cid, -manaNeededPerTarget)
                        end
                    end
                    if(#otherTargets == 0) then
                        break
                    end
                else
                    break
                end
            end
        end
    end
    return TRUE
end

It is protected so you cant shoot players in depot

player 1 stands outside depot with this wand
player 2 stands outside as an sacrefiece
player 3 stands inside depot

player 1 shoots player 2, and the damage doesnt bumps over to player 3 which is inside depot.

Here i still can`t atk more than 1 target.
 
There are 2 bugs in the script!

1º Bug
it`s bugged :/
if player 1 stand outside pz and player 2 stand in pz
and you attack player 1 the wand attack player 2 in pz too.

Is it protected so you cant shoot players in depot?

player 1 stands outside depot with this wand
player 2 stands outside as an sacrefiece
player 3 stands inside depot

player 1 shoots player 2, and the damage bumps over to player 3 which is inside depot.

2º Bug
in config:
PHP:
local hitExtraTargets = 2
local hitExtraTargetsInRange = 2
Was to attack only 2 players and sometimes attacking 3 players!
2players.png

3players.png
 
Is this script fixed yet ?
There are 2 bugs in the script!

1º Bug




2º Bug
in config:
PHP:
local hitExtraTargets = 2
local hitExtraTargetsInRange = 2
Was to attack only 2 players and sometimes attacking 3 players!
2players.png

3players.png
 
Try that:
Lua:
local combat = createCombatObject()
setCombatParam(combat, COMBAT_PARAM_BLOCKARMOR, 0)
setCombatParam(combat, COMBAT_PARAM_BLOCKSHIELD, 0)
setCombatParam(combat, COMBAT_PARAM_TYPE, COMBAT_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_EFFECT, CONST_ME_HOLYDAMAGE)
setCombatParam(combat, COMBAT_PARAM_DISTANCEEFFECT, CONST_ANI_HOLY)
setCombatFormula(combat, COMBAT_FORMULA_LEVELMAGIC, -0.2, -25, -0.2, -3)

local manaNeededPerTarget = 20
local hitExtraTargets = 2 -- number of extra targets, so it should attack our target + X other monsters/players
local hitExtraTargetsInRange = 2 -- distance to 'extra target' from our target


function onUseWeapon(cid, var)
	local ret = doCombat(cid, combat, var)
	if(ret == LUA_ERROR) then
		return LUA_ERROR
	end
	local manaSpent = manaNeededPerTarget
	local target = variantToNumber(var)
	local hitplayers = false
	if(target ~= 0) then
		if(isPlayer(target)) then
			hitplayers = true
		end
		local otherTargets = getSpectators(getCreaturePosition(target), hitExtraTargetsInRange, hitExtraTargetsInRange, false)
		if(#otherTargets > 0) then
			local i = 1
			while(i ~= #otherTargets) do
				local pid = otherTargets[i]
				if(isNpc(pid) or pid == cid or pid == target or (isPlayer(pid) and (not hitplayers or getTileInfo(getCreaturePosition(pid)).protection))) then
					table.remove(otherTargets, i)
				else
					i = i + 1
				end
			end
		end
		for i = 1, hitExtraTargets do
			if(#otherTargets > 0 and getCreatureMana(cid) >= manaSpent + manaNeededPerTarget) then	
				local randomId = math.random(1, #otherTargets)
				local nowHit = otherTargets[randomId]
				table.remove(otherTargets, randomId)
				ret = doCombat(cid, combat, numberToVariant(nowHit))
				if(ret ~= LUA_ERROR) then
					manaSpent = manaSpent + manaNeededPerTarget
				end
			else
				break
			end
		end
	end
	doPlayerAddSpentMana(cid, manaSpent)
	doCreatureAddMana(cid, -manaSpent)
	return true
end
NOT TESTED, I JUST WROTE IT IN NOTEPAD
 
Last edited:
Back
Top