Mercurial > wow > cyborg-mmo7
comparison WowObjects.lua @ 65:8b8b0bade520
Fixed support for mounts using the new MountJournal and mount IDs (no conversion of old profiles at the moment).
author | Jerome Vuarand <jerome.vuarand@gmail.com> |
---|---|
date | Thu, 23 Oct 2014 13:44:59 +0100 |
parents | 7cbd32de1fdd |
children | 840c9f09a707 |
comparison
equal
deleted
inserted
replaced
64:49ae7191821f | 65:8b8b0bade520 |
---|---|
349 -- PlaySound("igAbilityIconDrop") | 349 -- PlaySound("igAbilityIconDrop") |
350 return C_PetJournal.PickupPet(self.petID) | 350 return C_PetJournal.PickupPet(self.petID) |
351 end | 351 end |
352 | 352 |
353 function WowBattlePet_methods:SetBinding(key) | 353 function WowBattlePet_methods:SetBinding(key) |
354 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) | |
355 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | |
356 end | |
357 | |
358 ------------------------------------------------------------------------------ | |
359 | |
360 local function GetMountInfoEx(mountID) | |
361 -- special case for random mount | |
362 if mountID == 0xFFFFFFF then | |
363 return 0,"Interface/ICONS/ACHIEVEMENT_GUILDPERK_MOUNTUP" | |
364 end | |
365 | |
366 local spellID = CyborgMMO_MountMap[mountID] or CyborgMMO_LocalMountMap[mountID] | |
367 if not spellID then return nil,"not in database" end | |
368 | |
369 local mountIndex | |
370 for i=1,C_MountJournal.GetNumMounts() do | |
371 local _,spell,texture = C_MountJournal.GetMountInfo(i) -- :FIXME: this may fail too early in the session (like when loading saved data) | |
372 if spell==spellID then | |
373 return i,texture | |
374 end | |
375 end | |
376 | |
377 return nil,"not in journal" | |
378 end | |
379 | |
380 local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) | |
381 local WowMount_mt = {__index=WowMount_methods} | |
382 | |
383 local function WowMount(mountID) | |
384 local mountIndex,texture = GetMountInfoEx(mountID) | |
385 if not mountIndex then | |
386 -- the mount might have been removed from the game | |
387 return nil | |
388 end | |
389 | |
390 local self = WowObject("mount", mountID) | |
391 CyborgMMO_DPrint("creating mount binding:", mountID, texture) | |
392 | |
393 self.mountID = mountID | |
394 self.texture = texture | |
395 | |
396 setmetatable(self, WowMount_mt) | |
397 | |
398 return self | |
399 end | |
400 | |
401 function WowMount_methods:DoAction() | |
402 local mountIndex = GetMountInfoEx(self.mountID) | |
403 if not mountIndex then return end | |
404 | |
405 C_MountJournal.Summon(mountIndex) | |
406 end | |
407 | |
408 function WowMount_methods:Pickup() | |
409 local mountIndex = GetMountInfoEx(self.mountID) | |
410 if not mountIndex then return end | |
411 | |
412 return C_MountJournal.Pickup(mountIndex) | |
413 end | |
414 | |
415 function WowMount_methods:SetBinding(key) | |
354 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) | 416 local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) |
355 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") | 417 SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") |
356 end | 418 end |
357 | 419 |
358 ------------------------------------------------------------------------------ | 420 ------------------------------------------------------------------------------ |
414 object = WowCompanion(...) | 476 object = WowCompanion(...) |
415 elseif type == "equipmentset" then | 477 elseif type == "equipmentset" then |
416 object = WowEquipmentSet(...) | 478 object = WowEquipmentSet(...) |
417 elseif type == "battlepet" then | 479 elseif type == "battlepet" then |
418 object = WowBattlePet(...) | 480 object = WowBattlePet(...) |
481 elseif type == "mount" then | |
482 object = WowMount(...) | |
419 elseif type == "callback" then | 483 elseif type == "callback" then |
420 object = WowCallback(...) | 484 object = WowCallback(...) |
421 else | 485 else |
422 CyborgMMO_DPrint("unsupported wow object:", type, ...) | 486 CyborgMMO_DPrint("unsupported wow object:", type, ...) |
423 unsupported = true | 487 unsupported = true |