Mercurial > wow > cyborg-mmo7
diff 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 |
line wrap: on
line diff
--- a/WowObjects.lua Thu Oct 23 15:51:26 2014 +0100 +++ b/WowObjects.lua Thu Oct 23 17:11:47 2014 +0100 @@ -215,62 +215,6 @@ ------------------------------------------------------------------------------ -local WowCompanion_methods = setmetatable({}, {__index=WowObject_methods}) -local WowCompanion_mt = {__index=WowCompanion_methods} - -local function WowCompanion(spellID) - local texture = select(3, GetSpellInfo(spellID)) - if not texture then - return nil - end - - local self = WowObject("companion", spellID) - CyborgMMO_DPrint("creating companion binding:", type, spellID) - - self.spellID = spellID - self.texture = texture - - setmetatable(self, WowCompanion_mt) - - return self -end - -local function IdentifyCompanion(spellID) - for _,subtype in ipairs{'MOUNT', 'CRITTER'} do - for index=1,GetNumCompanions(subtype) do - local spellID2,_,active = select(3, GetCompanionInfo(subtype, index)) - if spellID2 == spellID then - return subtype,index,active - end - end - end -end - -function WowCompanion_methods:DoAction() - local subtype,index,active = IdentifyCompanion(self.spellID) --- if subtype == "MOUNT" and IsMounted() then - if subtype == "MOUNT" and active then - Dismount() - elseif subtype and index then - CallCompanion(subtype, index) - end -end - -function WowCompanion_methods:Pickup() --- PlaySound("igAbilityIconDrop") - local subtype,index = IdentifyCompanion(self.spellID) - if subtype and index then - return PickupCompanion(subtype, index) - end -end - -function WowCompanion_methods:SetBinding(key) - local buttonFrame,parentFrame,name = CyborgMMO_CallbackFactory:AddCallback(function() self:DoAction() end) - SetOverrideBindingClick(parentFrame, true, key, name, "LeftButton") -end - ------------------------------------------------------------------------------- - local WowEquipmentSet_methods = setmetatable({}, {__index=WowObject_methods}) local WowEquipmentSet_mt = {__index=WowEquipmentSet_methods} @@ -377,6 +321,30 @@ return nil,"not in journal" end +local function FindMountFromSpellID(spellID) + for mount,spell in pairs(CyborgMMO_MountMap) do + if spell==spellID then + return mount + end + end + for mount,spell in pairs(CyborgMMO_MountMap) do + if spell==spellID then + return mount + end + end + for i=1,C_MountJournal.GetNumMounts() do + local _,spell = C_MountJournal.GetMountInfo(i) + if spell==spellID then + local cursor = pack(GetCursorInfo()) + C_MountJournal.Pickup(i) + local _,mountID = GetCursorInfo() + ClearCursor() + return mountID + end + end + return nil +end + local WowMount_methods = setmetatable({}, {__index=WowObject_methods}) local WowMount_mt = {__index=WowMount_methods} @@ -473,7 +441,12 @@ elseif type == "spell" then object = WowSpell(...) elseif type == "companion" then - object = WowCompanion(...) + -- most likely a legacy mount in an old SavedVariables + local spellID = ... + local mountID = FindMountFromSpellID(spellID) + if mountID then + object = WowMount(mountID) + end elseif type == "equipmentset" then object = WowEquipmentSet(...) elseif type == "battlepet" then