PDA

View Full Version : what's wrong with this simple script?



jollebollen
12-29-2015, 11:38 PM
someone tried to help me to add monster count to this script and it doesnt work:


local Spells = {
{words = 'exori', hppc = 0, range = 1, mana = 200, count = 2, list = {'necromancer', 'blood haand', 'blood priest', 'zombie', 'gravedigger', 'blood hand', 'stalker', 'shadow pupil', 'skeleton warrior', 'skeleton', 'skeleton warrior', 'pirate skeleton', 'pirate ghost', 'tarnished spirit', 'ghost', 'zombie', 'lich', 'death blob', 'vampire bride', 'vampire viscount', 'banshee'}
}
}

local PvPRadiusSafety = 4
local MonsterRange = 1

function SafeRadius(radius)
for n, c in Creature.iPlayers() do
if c:DistanceFromSelf() < radius then
return true
end
end
end

Module.New("Count", function()
local mob = Self.GetTargets(MonsterRange)
local mobCount = 0
for i = 1, #mob do
if table.contains(Spells[i].list, mob[i]:Name()) then
mobCount = mobCount + 1
end
end
end)

BattleMessageProxy.OnReceive('shooter', function(proxy, message)
local givendmg = string.match(message, "(.+) due to your attack.")
if (givendmg) then
local id = Self.TargetID()
if (id ~= 0) then
local mp = Self.Mana()
local c = Creature.New(id)
for i = 1, #Spells do
if table.contains(Spells[i].list, c:Name():lower()) then
if Self.CanCastSpell(Spells[i].words) and mp > Spells[i].mana and c:HealthPercent() >= Spells[i].hppc and Spells[i].count >= mobCount then
local isUnsafe = SafeRadius(PvPRadiusSafety)
if not (isUnsafe) and c:DistanceFromSelf() <= Spells[i].range and Spells[i].count >= mobCount then
if c:isTarget() then
Self.Cast(Spells[i].words, Spells[i].mana)
end
end
break
end
end
end
end
end
end)

grave18
12-30-2015, 12:12 AM
Next time don't double your topic, just change the page ;f

local Spells = {
{words = 'exori flam', hppc = 0, range = 3, mana = 20, count = 3, list = {'rat', 'cave rat', 'bat', 'corym charlatan'}
}
}

local PvPRadiusSafety = 3
local MonsterRange = 7

function SafeRadius(radius)
for n, c in Creature.iPlayers() do
if c:DistanceFromSelf() < radius then
return true
end
end
end

function MonstersAround(list, radius)
local k = 0
for name, creature in Creature.iMonsters({distancefromself = {lt, radius}}) do
if (list ~= nil) then
if table.contains(list, name:lower()) then
k = k + 1
end
else
k = k + 1
end
end
return k
end

BattleMessageProxy.OnReceive('shooter', function(proxy, message)
local givendmg = string.match(message, "(.+) due to your attack.")
if (givendmg) then
local id = Self.TargetID()
if (id ~= 0) then
local mp = Self.Mana()
local c = Creature.New(id)
for i = 1, #Spells do
if table.contains(Spells[i].list, c:Name():lower()) then
if MonstersAround(Spells[i].list, MonsterRange) >= Spells[i].count then
if Self.CanCastSpell(Spells[i].words) and mp > Spells[i].mana and c:HealthPercent() >= Spells[i].hppc then
local isUnsafe = SafeRadius(PvPRadiusSafety)
if not (isUnsafe) and c:DistanceFromSelf() <= Spells[i].range then
if c:isTarget() then
Self.Cast(Spells[i].words, Spells[i].mana)
end
end
break
end
end
end
end
end
end
end)