vanilla-wow-addons – Blame information for rev 1

Subversion Repositories:
Rev:
Rev Author Line No. Line
1 office 1 dontattack = 0;
2  
3  
4 --Attack Command
5 function SmartPet_Attack()
6 local pet = UnitName("pet");
7 local target = UnitName("target");
8  
9 -- Check if Enabled
10 if not (SmartPet_Config.Enabled) then
11 SmartPet_AddDebugMessage("SmartPet Disabled, using default petAttack", "spew");
12 Pre_SmartPet_PetAttack();
13 return;
14 end
15  
16 if (SmartPet_Config.DebufCheck ) then
17 if (SmartPet_CheckDebuff()) then
18 UIErrorsFrame:AddMessage("Breakable DeBuff Found, not attacking", 0, 0, 1, 1.0, UIERRORS_HOLD_TIME);
19  
20 return;
21 end
22 end
23  
24 --Casts Spell if Spell Attack is active
25 SmartPetSpellAttack();
26  
27 if (not (pet == nil) and not ( UnitIsDead("pet") ) )then
28  
29 -- check for PVP Ability toggle
30 SmartPet_StartPVP();
31  
32 --Assist Other. If target is assistable player then we will have pet assist them
33 if ( UnitIsPlayer("target") ) and ( UnitCanCooperate("player", "target")) and (UnitIsEnemy("player", "targettarget")) and not (UnitIsDead("targettarget") ) then
34 player = target;
35 AssistUnit("target");
36 target = UnitName("target");
37  
38 if (target == nil) then
39 return;
40 end
41  
42 if not (UnitCanAttack("player", "target")) then
43 return;
44 end
45 message = SetMessage(pet, target, player, "assist_other");
46  
47 elseif (UnitCanAttack("player", "target")) then
48  
49 -- Assist Player
50 if UnitIsTappedByPlayer("target") then
51 message = SetMessage(pet, target, "me", "assist_me");
52  
53 -- Attack Mob
54 else
55 message = SetMessage(pet, target, "none", "attack");
56 end
57  
58 end
59  
60 if (UnitExists("target") and UnitCanAttack("player", "target") ) then
61  
62 if not ( UnitIsDead("target") ) then
63 SmartPet_AddDebugMessage("Attack", "spew");
64 SmartPet_AddDebugMessage(SmartPet_Vars.lastAttack, "spew");
65  
66 SmartPet_AddDebugMessage(SmartPet_Config.AlertTimeout, "spew");
67  
68 -- Check Alert
69 if (SmartPet_Config.Alert and ((GetTime() - SmartPet_Vars.lastAttack) > SmartPet_Config.AlertTimeout) ) then
70 SmartPet_SendChatMessage(message,string.upper(SMARTPET_CHANNELS_DROPDOWN_LIST[SmartPet_Config.AlertChannel]),SmartPet_Config.AlertChannelNumber);
71 SmartPet_Vars.lastAttack = GetTime();
72 end
73  
74 Pre_SmartPet_PetAttack();
75  
76 --Check to see if we want to use Dash/Dive on attack start
77 SmartPetChargeCheck();
78 end
79 else
80 --Turns Pet Attack command into Pet Follow if no target is selected
81 PetFollow();
82 end
83 end
84 end
85  
86  
87 --Casts a Selected Spell on attack command
88 function SmartPetChargeCheck()
89 if ((SmartPet_Config.RushAttack) and (not SmartPet_Vars.InCombat))then
90 local SkillToUse = "";
91 SmartPet_AddDebugMessage("Trying to cast Dash/Dive", "spew");
92 if (SmartPet_Actions["Dash"].id > 0) then
93 SkillToUse = "Dash";
94 elseif (SmartPet_Actions["Dive"].id > 0) then
95 SkillToUse = "Dive";
96 else
97 SmartPet_AddDebugMessage("Dash/Dive Not Found", "spew");
98 --SkillToUse = "";
99 return;
100 end
101  
102 local start, duration = GetSpellCooldown((SmartPet_Actions[SkillToUse].id), "Pet");
103 if ( start == 0 and duration == 0) then
104 CastSpell((SmartPet_Actions[SkillToUse].id), "Pet");
105 end
106 end
107  
108 end
109  
110 -- PVP Start Handler. Checks to see if combat is PVP and optimises settings for it
111 function SmartPet_StartPVP()
112 if ((UnitExists("target")) and (UnitIsPlayer("target")) and (UnitCanAttack("player", "target"))) then
113 if not (SmartPet_Vars.InPVP) then
114 SmartPet_AddDebugMessage("Storing prePVP Settings", "spew");
115 SmartPet_Vars.InPVP = true;
116 SmartPet_Vars.UseTaunt = SmartPet_Config.UseTaunt;
117 SmartPet_Vars.UseDetaunt = SmartPet_Config.UseDetaunt;
118 SmartPet_Vars.AutoCower = SmartPet_Config.AutoCower;
119 if (SmartPet_Config.UseTaunt) then
120 SmartPet_ToggleUse(SmartPet_Actions["Taunt"].index);
121 end
122 if (SmartPet_Config.UseDetaunt) then
123 SmartPet_ToggleUse(SmartPet_Actions["Detaunt"].index);
124 end
125 SmartPet_Config.AutoCower = false;
126 --SmartPet_EnableAction("Burst");
127 --SmartPet_EnableAction("Sustain");
128 end
129 end
130 end
131  
132 -- PVP End Handler. Resets taunt variables to orginal config that was changed on entering PVP
133 function SmartPet_EndPVP()
134 SmartPet_AddDebugMessage("Restoring to PrePVP conditions", "spew");
135 SmartPet_Vars.InPVP = false;
136 if (SmartPet_Vars.UseTaunt) then
137 SmartPet_ToggleUse(SmartPet_Actions["Taunt"].index);
138 end
139 if (SmartPet_Vars.UseDetaunt) then
140 SmartPet_ToggleUse(SmartPet_Actions["Detaunt"].index);
141 end
142 if (SmartPet_Vars.AutoCower) then
143 SmartPet_Config.AutoCower = true;
144 end
145 end
146  
147  
148  
149 function SmartPetAttack_OnEvent()
150  
151  
152 if ( event == "PLAYER_REGEN_DISABLED") then
153 SmartPet_CheckDebuff();
154 end
155  
156 if ( event == "CHAT_MSG_SPELL_SELF_DAMAGE" or event == "CHAT_MSG_COMBAT_SELF_MISSES" or event == "CHAT_MSG_COMBAT_SELF_HITS") then
157 SmartPet_CheckDebuff();
158 elseif( event == "PLAYER_ENTER_COMBAT") then
159 SmartPet_CheckDebuff();
160 elseif( event == "PLAYER_LEAVE_COMBAT" ) then
161 SmartPet_CheckDebuff();
162 elseif( event == "PLAYER_REGEN_ENABLED") then
163 SmartPet_CheckDebuff();
164 elseif( event == "PLAYER_REGEN_DISABLED") then
165 SmartPet_CheckDebuff();
166 elseif( event == "SPELLCAST_START") then
167 SmartPet_CheckDebuff();
168 elseif( event == "SPELLCAST_STOP") then
169 SmartPet_CheckDebuff();
170 elseif( event == "PLAYER_TARGET_CHANGED") then
171 SmartPet_CheckDebuff();
172 elseif( event == "START_AUTOREPEAT_SPELL") then
173 SmartPet_CheckDebuff();
174 elseif( event == "STOP_AUTOREPEAT_SPELL") then
175 SmartPet_CheckDebuff();
176 elseif( event == "PLAYER_CONTROL_LOST") then
177 SmartPet_CheckDebuff();
178 elseif( event == "PLAYER_CONTRL_GAINED") then
179 SmartPet_CheckDebuff();
180 elseif( event == "UI_ERROR_MESSAGE") then
181 SmartPet_CheckDebuff();
182 end
183  
184 end
185  
186 function SmartPetAttack_OnLoad()
187 this:RegisterEvent("PLAYER_ENTER_COMBAT");
188 this:RegisterEvent("PLAYER_LEAVE_COMBAT");
189 this:RegisterEvent("PLAYER_TARGET_CHANGED");
190 this:RegisterEvent("START_AUTOREPEAT_SPELL");
191 this:RegisterEvent("STOP_AUTOREPEAT_SPELL");
192 this:RegisterEvent("PLAYER_CONTROL_LOST");
193 this:RegisterEvent("UI_ERROR_MESSAGE");
194 this:RegisterEvent("SPELLCAST_START");
195 this:RegisterEvent("SPELLCAST_STOP");
196 this:RegisterEvent("PLAYER_REGEN_DISABLED");
197 this:RegisterEvent("PLAYER_REGEN_ENABLED");
198 this:RegisterEvent("CHAT_MSG_MONSTER_EMOTE");
199 this:RegisterEvent("PET_ATTACK_START");
200 this:RegisterEvent("PET_ATTACK_STOP");
201 this:RegisterEvent("VARIABLES_LOADED");
202 end
203  
204 -- Checks for debufs on the target
205 function SmartPet_CheckDebuff()
206 unit = "target";
207 SmartPetTip:ClearLines();
208  
209 for j = 1, 10 do
210 local msg = "";
211  
212 if (UnitDebuff(unit,j)) then
213 SmartPetTip:SetUnitDebuff(unit, j);
214 msg = SmartPetTipTextLeft1:GetText();
215 --UIErrorsFrame:AddMessage(msg, 0, 0, 1, 1.0, 2);
216 for i = 1, getn(SMARTPET_NOATTACK), 1 do
217 if (msg == SMARTPET_NOATTACK[i]) then
218 --UIErrorsFrame:AddMessage("Debuf found", 0, 0, 1, 1.0, 1);
219 return "true";
220 end
221 end
222 elseif (not UnitDebuff(unit,j)) then
223 pop = 0;
224 break;
225 end
226  
227 end
228 end