From fc47b51d23d8fa0fd99cfa18a5152fdf451b648a Mon Sep 17 00:00:00 2001 From: Inky Date: Mon, 20 May 2019 16:08:51 +0300 Subject: [PATCH] Changed: use one lua bind to retrieve itemInfo --HG-- branch : lua --- .../client/src/interface_v3/dbctrl_sheet.cpp | 66 ++++++++----------- .../client/src/interface_v3/dbctrl_sheet.h | 20 ++---- 2 files changed, 33 insertions(+), 53 deletions(-) diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp index 50cdea91e..c809c5d4a 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.cpp @@ -135,54 +135,40 @@ int CDBCtrlSheet::luaGetDraggedSheet(CLuaState &ls) } // *************************************************************************** -int CDBCtrlSheet::luaGetHpBuff(CLuaState &ls) +int CDBCtrlSheet::luaGetItemInfo(CLuaState &ls) { CDBCtrlSheet *ctrlSheet = const_cast(this); - uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); - CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - - ls.push(itemInfo.HpBuff); - - return 1; -} - -// *************************************************************************** -int CDBCtrlSheet::luaGetSapBuff(CLuaState &ls) -{ - CDBCtrlSheet *ctrlSheet = const_cast(this); - uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); - CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - - ls.push(itemInfo.SapBuff); - - return 1; -} - -// *************************************************************************** -int CDBCtrlSheet::luaGetFocusBuff(CLuaState &ls) -{ - CDBCtrlSheet *ctrlSheet = const_cast(this); - uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); - CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - - ls.push(itemInfo.FocusBuff); - - return 1; -} - -// *************************************************************************** -int CDBCtrlSheet::luaGetStaBuff(CLuaState &ls) -{ - CDBCtrlSheet *ctrlSheet = const_cast(this); - uint32 itemSlotId= getInventory().getItemSlotId(ctrlSheet); + uint32 itemSlotId = getInventory().getItemSlotId(ctrlSheet); CClientItemInfo itemInfo = getInventory().getItemInfo(itemSlotId); - ls.push(itemInfo.StaBuff); + ls.newTable(); + CLuaObject out(ls); + // for now all but magic + out.setValue("CurrentDamage", itemInfo.CurrentDamage); + out.setValue("MaxDamage", itemInfo.MaxDamage); + out.setValue("DodgeModifier", itemInfo.DodgeModifier); + out.setValue("ParryModifier", itemInfo.ParryModifier); + out.setValue("AdversaryDodgeModifier", itemInfo.AdversaryDodgeModifier); + out.setValue("AdversaryParryModifier", itemInfo.AdversaryParryModifier); + out.setValue("Hp", itemInfo.Hp); + out.setValue("HpMax", itemInfo.HpMax); + out.setValue("Range", itemInfo.Range); + out.setValue("HpBuff", itemInfo.HpBuff); + out.setValue("SapBuff", itemInfo.SapBuff); + out.setValue("StaBuff", itemInfo.StaBuff); + out.setValue("FocusBuff", itemInfo.FocusBuff); + out.setValue("SapLoadCurrent", itemInfo.SapLoadCurrent); + out.setValue("SapLoadMax", itemInfo.SapLoadMax); + out.setValue("ProtectionFactor", itemInfo.ProtectionFactor); + out.setValue("MaxSlashingProtection", itemInfo.MaxSlashingProtection); + out.setValue("MaxPiercingProtection", itemInfo.MaxPiercingProtection); + out.setValue("MaxBluntProtection", itemInfo.MaxBluntProtection); + out.setValue("WearEquipmentMalus", itemInfo.WearEquipmentMalus); + out.push(); return 1; } - // *************************************************************************** int CDBCtrlSheet::luaGetName(CLuaState &ls) { diff --git a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h index ad1bc49a9..40218f3e1 100644 --- a/code/ryzom/client/src/interface_v3/dbctrl_sheet.h +++ b/code/ryzom/client/src/interface_v3/dbctrl_sheet.h @@ -279,22 +279,16 @@ public: REFLECT_STRING ("on_drop_params", getParamsOnDrop, setParamsOnDrop); REFLECT_STRING ("on_can_drop", getActionOnCanDrop, setActionOnCanDrop); REFLECT_STRING ("on_can_drop_params", getParamsOnCanDrop, setParamsOnCanDrop); - REFLECT_LUA_METHOD("getDraggedSheet", luaGetDraggedSheet) - REFLECT_LUA_METHOD("getHpBuff", luaGetHpBuff) - REFLECT_LUA_METHOD("getSapBuff", luaGetSapBuff) - REFLECT_LUA_METHOD("getFocusBuff", luaGetFocusBuff) - REFLECT_LUA_METHOD("getStaBuff", luaGetStaBuff) - REFLECT_LUA_METHOD("getName", luaGetName) - REFLECT_LUA_METHOD("getCreatorName", luaGetCreatorName) - REFLECT_LUA_METHOD("waitInfo", luaWaitInfo) - REFLECT_LUA_METHOD("buildCrystallizedSpellListBrick", luaBuildCrystallizedSpellListBrick) + REFLECT_LUA_METHOD("getDraggedSheet", luaGetDraggedSheet); + REFLECT_LUA_METHOD("getItemInfo", luaGetItemInfo); + REFLECT_LUA_METHOD("getName", luaGetName); + REFLECT_LUA_METHOD("getCreatorName", luaGetCreatorName); + REFLECT_LUA_METHOD("waitInfo", luaWaitInfo); + REFLECT_LUA_METHOD("buildCrystallizedSpellListBrick", luaBuildCrystallizedSpellListBrick); REFLECT_EXPORT_END int luaGetDraggedSheet(CLuaState &ls); - int luaGetHpBuff(CLuaState &ls); - int luaGetSapBuff(CLuaState &ls); - int luaGetFocusBuff(CLuaState &ls); - int luaGetStaBuff(CLuaState &ls); + int luaGetItemInfo(CLuaState &ls); int luaGetName(CLuaState &ls); int luaGetCreatorName(CLuaState &ls); int luaWaitInfo(CLuaState &ls);