Untitled

 avatar
unknown
lua
a year ago
1.5 kB
4
Indexable
local matrix = {
	{0, 1, 0},
	{1, 3, 1},
	{0, 1, 0}
}

function onUseWeapon(cid, var)

	local weapon = getPlayerWeapon(cid)
	local extraAttack = getItemAttribute(weapon.uid, "wand_attack") or 0

	local target = getCreatureTarget(cid)
	local targetPosition = getThingPos(target)
	local matrixPositions = getMatrixPositions(targetPosition, matrix)

	local details = { combat = COMBAT_DEATHDAMAGE, effect = CONST_ME_MORTAREA, distance = CONST_ANI_SUDDENDEATH }
	if not isSorcerer(cid) then
		details = { combat = COMBAT_ICEDAMAGE, effect = CONST_ME_GIANTICE, distance = CONST_ANI_ICE }
	end

	local value = getPlayerStorageValue(cid, 6999)
	if value == 3 then
		details = { combat = COMBAT_EARTHDAMAGE, effect = 45, distance = 29 }
	elseif value == 4 then
		details = { combat = COMBAT_FIREDAMAGE, effect = 6, distance = 3 }
	end

	local min = 300000000 + extraAttack
	local max = 350000000 + extraAttack

	for i = 1, #matrixPositions do

		local position = matrixPositions[i]
		local tileInfo = getTileInfo(position)

		if isTileCombatAvailable(position) then

			local creatures = getTileCreatures(position)
			for i = 1, #creatures do
				local targetCid = creatures[i]

				if isMonster(targetCid) or isPlayer(targetCid) then
					doTargetCombatHealth(cid, targetCid, details.combat, -min, -max, CONST_ME_NONE, true)
				end
			end

			doSendMagicEffect(position, details.effect)
		end
	end

	doSendDistanceShoot(getThingPos(cid), targetPosition, details.distance)
	return true
end
Editor is loading...
Leave a Comment