Mercurial > wow > cyborg-mmo7
comparison WowObjects.lua @ 68:840c9f09a707 v6.0.3-1
Removed the old companion code, and convert saved ones (which should already be mounts, not critters) to the 'mount' type.
author | Jerome Vuarand <jerome.vuarand@gmail.com> |
---|---|
date | Thu, 23 Oct 2014 17:11:47 +0100 |
parents | 8b8b0bade520 |
children |
comparison
equal
deleted
inserted
replaced
67:2d6684c270b9 | 68:840c9f09a707 |
---|---|
213 SetOverrideBindingMacro(CyborgMMO_CallbackFactory.Frame, true, key, self.name) | 213 SetOverrideBindingMacro(CyborgMMO_CallbackFactory.Frame, true, key, self.name) |
214 end | 214 end |
215 | 215 |
216 ------------------------------------------------------------------------------ | 216 ------------------------------------------------------------------------------ |
217 | 217 |
218 local WowCompanion_methods = setmetatable({}, {__index=WowObject_methods}) | |
219 local WowCompanion_mt = {__index=WowCompanion_methods} | |
220 | |
221 local function WowCompanion(spellID) | |
222 local texture = select(3, GetSpellInfo(spellID)) | |
223 if not texture then | |
224 return nil | |
225 end | |
226 | |
227 local self = WowObject("companion", spellID) | |
228 CyborgMMO_DPrint("creating companion binding:", type, spellID) | |
229 | |
230 self.spellID = spellID | |
231 self.texture = texture | |
232 | |
233 setmetatable(self, WowCompanion_mt) | |
234 | |
235 return self | |
236 end | |
237 | |
238 local function IdentifyCompanion(spellID) | |
239 for _,subtype in ipairs{'MOUNT', 'CRITTER'} do | |
240 for index=1,GetNumCompanions(subtype) do | |
241 local spellID2,_,active = select(3, GetCompanionInfo(subtype, index)) | |
242 if spellID2 == spellID then | |
243 return subtype,index,active | |
244 end | |
245 end | |
246 end | |
247 end | |
248 | |
249 function WowCompanion_methods:DoAction() | |
250 local subtype,index,active = IdentifyCompanion(self.spellID) | |
251 -- if subtype == "MOUNT" and IsMounted() then | |
252 if subtype == "MOUNT" and active then | |
253 Dismount() | |
254 elseif subtype and index then | |
255 CallCompanion(subtype, index) | |
256 end | |
257 end | |
258 | |
259 function WowCompanion_methods:Pickup() | |
260 -- PlaySound("igAbilityIconDrop") | |
261 local subtype,index = IdentifyCompanion(self.spellID) | |
262 if subtype and index then | |
263 return PickupCompanion(subtype, index) | |
264 end | |
265 end | |
266 | |
267 function WowCompanion_methods:SetBinding(key) | |
268 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) | |
269 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
270 end | |
271 | |
272 ------------------------------------------------------------------------------ | |
273 | |
274 local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods}) | 218 local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods}) |
275 local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods} | 219 local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods} |
276 | 220 |
277 local function WowEquipmentSet(name) | 221 local function WowEquipmentSet(name) |
278 local texture = GetEquipmentSetInfoByName(name) | 222 local texture = GetEquipmentSetInfoByName(name) |
373 return i,texture | 317 return i,texture |
374 end | 318 end |
375 end | 319 end |
376 | 320 |
377 return nil,"not in journal" | 321 return nil,"not in journal" |
322 end | |
323 | |
324 local function FindMountFromSpellID(spellID) | |
325 for mount,spell in pairs(CyborgMMO_MountMap) do | |
326 if spell==spellID then | |
327 return mount | |
328 end | |
329 end | |
330 for mount,spell in pairs(CyborgMMO_MountMap) do | |
331 if spell==spellID then | |
332 return mount | |
333 end | |
334 end | |
335 for i=1,C_MountJournal.GetNumMounts() do | |
336 local _,spell = C_MountJournal.GetMountInfo(i) | |
337 if spell==spellID then | |
338 local cursor = pack(GetCursorInfo()) | |
339 C_MountJournal.Pickup(i) | |
340 local _,mountID = GetCursorInfo() | |
341 ClearCursor() | |
342 return mountID | |
343 end | |
344 end | |
345 return nil | |
378 end | 346 end |
379 | 347 |
380 local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) | 348 local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) |
381 local WowMount_mt = {__index=WowMount_methods} | 349 local WowMount_mt = {__index=WowMount_methods} |
382 | 350 |
471 elseif type == "macro" then | 439 elseif type == "macro" then |
472 object = WowMacro(...) | 440 object = WowMacro(...) |
473 elseif type == "spell" then | 441 elseif type == "spell" then |
474 object = WowSpell(...) | 442 object = WowSpell(...) |
475 elseif type == "companion" then | 443 elseif type == "companion" then |
476 object = WowCompanion(...) | 444 -- most likely a legacy mount in an old SavedVariables |
445 local spellID = ... | |
446 local mountID = FindMountFromSpellID(spellID) | |
447 if mountID then | |
448 object = WowMount(mountID) | |
449 end | |
477 elseif type == "equipmentset" then | 450 elseif type == "equipmentset" then |
478 object = WowEquipmentSet(...) | 451 object = WowEquipmentSet(...) |
479 elseif type == "battlepet" then | 452 elseif type == "battlepet" then |
480 object = WowBattlePet(...) | 453 object = WowBattlePet(...) |
481 elseif type == "mount" then | 454 elseif type == "mount" then |