View difference between Paste ID: 6UDJXMWG and uBUUDtEn
SHOW: | | - or go back to the newest paste.
1-
dofile("SyntaxLuaLib.lua")
1+
--[[
2-
2+
        Instructions:
3-
local info = [[
3+
                Attacks are prioritized least to greatest.
4
 
5-
Description: Executes area spells on certain conditions
5+
                Required parameters:
6
                        words = spell words or rune id
7-
Version: 2.0.10 (updated 02.07.2012)]]
7+
                        min = minimum monster amount to trigger spell/rune
8-
8+
                        distance = the max range of the attack
9-
local config = {
9+
 
10-
	attacks = {
10+
                Optional parameters:
11-
		--[[
11+
                        max = the max monsters the spell will attack
12-
		spells should be prioritized from top to bottom, eg: exori gran will be attempted before exori or exori mas.
12+
                        mana = the minimum mana you want to have before casting
13-
		
13+
                        padding = the extra sqm's to check for players PAST the attack distance (default is 0)
14-
		players:
14+
                        needsTarget = the attack needs a target (exori hur, etc)
15-
			true = the area will include players in the threshold
15+
                        needsDirection = spells most effective when facing target (exori min)
16-
			false = the area will only count the monsters in the area
16+
                        multiFloor = check for players above/below (stairhop skulling)
17-
		
17+
                        ignoreParty = ignore player checks for party members
18-
		aggressive:
18+
                        whiteList = table of players to ignore
19-
			0 = attack triggers when no players are in the area.
19+
                        targetList = table of monsters to attack, to attack all do not specify this option
20-
			1 = attack triggers when only war enemies and skulled players, noone else.
20+
 
21-
			2 = attack triggers when innocents are in the area but not when friendlies are.
21+
]]
22-
			3 = attack triggers when friendlies are in the area but not when innocents are.
22+
 
23-
			4 = attack triggers without any regards to players in the area.
23+
 
24-
		]]
24+
attack = {}
25-
		--{words="exori gran", threshold=5, mana=50, radius=1, aggressive=0, players=false},
25+
attack[1] = {words="exori gran", min=5, distance=1, padding=2, multiFloor=true, ignoreParty=false, whiteList={"Syntax", "DarkstaR"}}
26-
		{words="exori", threshold=2, mana=30, radius=1, aggressive=0, players=false},
26+
attack[2] = {words="exori min", min=3, mana=100, needsDirection=true, distance=1, padding=2, multiFloor=true, ignoreParty=true, targetList={"Dragon"}}
27-
		--{words="exori mas", threshold =7, mana=80, radius=4, aggressive=0, players=false}
27+
attack[3] = {words="exori", min=2, distance=1, padding=2, multiFloor=true, ignoreParty=true}
28-
	}
28+
attack[4] = {words="exori hur", min=1, max=1, needsTarget=true, distance=1, padding=0, multiFloor=false, ignoreParty=true}
29-
}
29+
attack[5] = {words=3191, min=3, distance=3, padding=2, multiFloor=true, ignoreParty=true} -- gfb rune
30-
30+
 
31-
local function think()
31+
 
32-
	for _, info in ipairs(config.attacks)do
32+
function getTargetCount(distance, padding, multiFloor, ignoreParty, whiteList, targetList)
33-
		local amount = areaTargetAmount(info.radius, info.aggressive, info.players)
33+
        local n = 0
34-
		if(amount)then
34+
        padding = padding or 0
35-
			if(amount >= info.threshold)then
35+
        whiteList = whiteList or {}
36-
				cast(info.words, info.mana)
36+
        targetList = targetList or {}
37-
			end
37+
        for i = CREATURES_LOW, CREATURES_HIGH do
38-
		end
38+
                local cid = Creature.GetFromIndex(i)
39-
	end
39+
                local checkPad = cid:isPlayer() and padding or 0
40
                if(cid:isValid() and cid:isVisible() and cid:isAlive() and cid:DistanceFromSelf() <= (distance + checkPad) and not cid:isSelf())then
41-
41+
                        if(getSelfPosition().z == cid:Position().z or (multiFloor and cid:isPlayer()))then
42-
print(info)
42+
                                if(cid:isPlayer() and (not cid:isPartyMember() or not ignoreParty) and not table.find(whiteList, cid:Name(), false))then
43-
wait(5000)
43+
                                        return 0
44-
while (true) do
44+
                                elseif(cid:isMonster() and (table.find(targetList, cid:Name(), false) or #targetList<1))then
45-
	think()
45+
                                        n = n + 1
46-
	wait(500)
46+
                                end
47-
end
47+
                        end
48
                end
49
        end
50
        return n
51
end
52
 
53
function main()
54
        for i = 1, #attack do
55
                local atk = attack[i]
56
                local count = getTargetCount(atk.distance, atk.padding, atk.multiFloor, atk.ignoreParty, atk.whiteList, atk.targetList)
57
                if(count > 0)then
58
                        if(count >= atk.min and count <= ((atk.max == nil) and count or atk.max))then
59
                                if(type(atk.words) == 'number')then
60
                                        Self.UseItemWithMe(atk.words)
61
                                        wait(900, 1200)
62
                                elseif(Self.CanCastSpell(atk.words) and (not atk.mana or Self.Mana() >= atk.mana))then
63
                                        local target = Creature.GetByID(Self.TargetID())
64
                                        if(atk.needsTarget or atk.needsDirection)then
65
                                                if(target:isOnScreen() and target:isVisible() and target:isAlive())then
66
                                                        if(target:DistanceFromSelf() <= atk.distance)then
67
                                                                if(atk.needsDirection)then
68
                                                                        local pos, toPos = getSelfPosition(), target:Position()
69
                                                                        local dir = pos.x > toPos.x and WEST or pos.x < toPos.x and EAST or pos.y > toPos.y and NORTH or SOUTH
70
                                                                        Self.Turn(dir)
71
                                                                        wait(100, 200)
72
                                                                else
73
                                                                        Self.Say(atk.words)
74
                                                                end
75
                                                        end
76
                                                end
77
                                        end
78
                                        if(not atk.needsTarget)then
79
                                                Self.Say(atk.words)
80
                                        end
81
                                        wait(600, 1000)
82
                                end
83
                        end
84
                end
85
        end
86
end
87
 
88
print([[
89
Name: Auto Area Attack
90
Description: Shoots area spells/rune on certain conditions
91
Author: Cavitt Glover (Syntax)
92
Version: 5.0.00 (updated 11.26.2012)]])
93
wait(2000)
94
 
95
registerEventListener(TIMER_TICK, "main")