From 90ff2a2d7b72968c2c685a99ca50e530089a9162 Mon Sep 17 00:00:00 2001 From: shen <> Date: Tue, 20 Oct 2026 00:06:46 -0700 Subject: [PATCH] feat: add costume slots, shining types, and enchant stone targeting --- .../ScriptLib/Ava2NativeDataScript.inc | 12 ++- .../ScriptLib/Ava2NativeInterfacesScript.inc | 93 ++++++++++--------- src/platform/ScriptLib/CostumeAttrScript.inc | 13 ++- src/platform/ScriptLib/NativeTrackScript.inc | 12 ++- src/platform/ScriptLib/PickupScript.inc | 9 ++ src/port/GameLib/ItemData.h | 9 ++ src/port/UserInterface/InstanceBase.h | 4 + .../PythonCharacterManagerModule.cpp | 4 + src/port/UserInterface/PythonItemModule.cpp | 21 +++++ src/port/UserInterface/PythonPlayerModule.cpp | 28 +++++- tests/port/port_python_ui_modules_test.cpp | 21 ++++- 11 files changed, 170 insertions(+), 56 deletions(-) diff --git a/src/platform/ScriptLib/Ava2NativeDataScript.inc b/src/platform/ScriptLib/Ava2NativeDataScript.inc index a05091ef..b203ba2e 100644 --- a/src/platform/ScriptLib/Ava2NativeDataScript.inc +++ b/src/platform/ScriptLib/Ava2NativeDataScript.inc @@ -7,7 +7,17 @@ _built=False;_catalogue=None;_categories={};_costumes={};_chests={};_monsters={} def Load(): global _catalogue,_built - if _catalogue is None:_catalogue=Catalogue(pack.Get('wiki/catalogue.txt')) + if _catalogue is None: + raw=pack.Get('wiki/catalogue.txt') + if raw: + try:_catalogue=Catalogue(raw) + except Exception:_catalogue=None + if _catalogue is None: + class Dummy(object): + def __init__(self):self.items={};self.mobs={};self.recipes={};self.version='' + def FindItem(self,v):return None + def FindMob(self,v):return None + _catalogue=Dummy() if _built or not item.SelectItemWiki(19):return _catalogue _built=True jobs=(item.ITEM_ANTIFLAG_WARRIOR,item.ITEM_ANTIFLAG_ASSASSIN,item.ITEM_ANTIFLAG_SURA,item.ITEM_ANTIFLAG_SHAMAN) diff --git a/src/platform/ScriptLib/Ava2NativeInterfacesScript.inc b/src/platform/ScriptLib/Ava2NativeInterfacesScript.inc index 77ccfe46..548f991f 100644 --- a/src/platform/ScriptLib/Ava2NativeInterfacesScript.inc +++ b/src/platform/ScriptLib/Ava2NativeInterfacesScript.inc @@ -31,51 +31,54 @@ localeInfo.NumberToMoneyString=_FormatMoney64 for key,text in {'TARGET_INFO_RESIST_BELL':'铃铛抗性','TARGET_INFO_RESIST_BOW':'弓箭抗性','TARGET_INFO_RESIST_DAGGER':'匕首抗性','TARGET_INFO_RESIST_FAN':'扇子抗性','TARGET_INFO_RESIST_MAGIC':'魔法抗性','TARGET_INFO_RESIST_SWORD':'剑术抗性','TARGET_INFO_RESIST_TWOHAND':'双手武器抗性'}.items():setattr(localeInfo,key,L(text+':%d%%')) # Keep the original finder interactions while localizing its literal Worldard labels. -import uiDropItem -_dropLoad=uiDropItem.DropItemWindows.LoadWindow -_dropInfo=uiDropItem.DropItemWindows.LoadInfo -_dropReady=uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING -_dropSearch=uiDropItem.DropItemWindows.SearchItem -def DropValue(self): - ui.EditLine.OnIMEUpdate(self.ItemNameValue) - text=self.ItemNameValue.GetText().strip();self.get_vnum=-1 - dropdown=self.DropDownList;dropdown.Clear() - matches=[row for row in uiDropItem.ITEM_LIST if text and (row['name'].lower().startswith(text.lower()) or str(row['vnum'])==text)][:10] - for row in matches: - dropdown.AppendItem(row['name'],row['vnum']) - if str(row['vnum'])==text or row['name'].lower()==text.lower():self.get_vnum=row['vnum'] - dropdown.DropList.SetViewItemCount(len(matches));dropdown.DropList.SetBasePos(0) - dropdown.dropped=int(bool(matches)) - if matches:dropdown.Show() - else:dropdown.Hide() -def DropSearch(self): - if self.get_vnum<=0:return - import renderTarget - renderTarget.SetVisibility(self.RENDER_TARGET_INDEX,False) - self.ModelRender.Hide();self.ModelName1.SetText('');self.ModelName2.SetText('');data._data=[] - self.LoadInfo();self.TotalResultados.SetText(L('查询中…'));self.TotalResultados.Show() - _dropSearch(self) -def DropReady(self): - _dropReady(self);self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates)) - self.TotalPages.SetText('%d/%d'%(1 if not self.total_dates else self.page_actual,max(1,(self.total_dates+self.pages_view-1)//self.pages_view))) -def DropFailed(self):self.TotalResultados.SetText(L('查询失败,请重试或重新连接')) -uiDropItem.DropItemWindows._DropItemWindows__OnValueUpdate=DropValue -uiDropItem.DropItemWindows.SearchItem=DropSearch -uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING=DropReady -uiDropItem.DropItemWindows.NativeQueryFailed=DropFailed -def DropLoad(self): - _dropLoad(self) - self.GetChild('TitleName').SetText(L('掉落查询')) - self.ButtonSearch.SetToolTipText(L('查询掉落来源')) - self.ButtonDelete.SetToolTipText(L('清空查询')) -def DropInfo(self): - _dropInfo(self) - for index in xrange(min(self.pages_view,max(0,self.total_dates-(self.page_actual-1)*self.pages_view))): - row=index+(self.page_actual-1)*self.pages_view - self.ButtonsSelect['Cantidad_Item_%d'%index].SetText(L('数量:%d')%self.FReturnInfo('count_item',row)) - self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates)) -uiDropItem.DropItemWindows.LoadWindow=DropLoad -uiDropItem.DropItemWindows.LoadInfo=DropInfo +try: + import uiDropItem + if hasattr(uiDropItem, 'DropItemWindows'): + _dropLoad=uiDropItem.DropItemWindows.LoadWindow + _dropInfo=uiDropItem.DropItemWindows.LoadInfo + _dropReady=uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING + _dropSearch=uiDropItem.DropItemWindows.SearchItem + def DropValue(self): + ui.EditLine.OnIMEUpdate(self.ItemNameValue) + text=self.ItemNameValue.GetText().strip();self.get_vnum=-1 + dropdown=self.DropDownList;dropdown.Clear() + matches=[row for row in getattr(uiDropItem, 'ITEM_LIST', ()) if text and (row['name'].lower().startswith(text.lower()) or str(row['vnum'])==text)][:10] + for row in matches: + dropdown.AppendItem(row['name'],row['vnum']) + if str(row['vnum'])==text or row['name'].lower()==text.lower():self.get_vnum=row['vnum'] + dropdown.DropList.SetViewItemCount(len(matches));dropdown.DropList.SetBasePos(0) + dropdown.dropped=int(bool(matches)) + if matches:dropdown.Show() + else:dropdown.Hide() + def DropSearch(self): + if self.get_vnum<=0:return + import renderTarget + renderTarget.SetVisibility(self.RENDER_TARGET_INDEX,False) + self.ModelRender.Hide();self.ModelName1.SetText('');self.ModelName2.SetText('');data._data=[] + self.LoadInfo();self.TotalResultados.SetText(L('查询中…'));self.TotalResultados.Show() + _dropSearch(self) + def DropReady(self): + _dropReady(self);self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates)) + self.TotalPages.SetText('%d/%d'%(1 if not self.total_dates else self.page_actual,max(1,(self.total_dates+self.pages_view-1)//self.pages_view))) + def DropFailed(self):self.TotalResultados.SetText(L('查询失败,请重试或重新连接')) + uiDropItem.DropItemWindows._DropItemWindows__OnValueUpdate=DropValue + uiDropItem.DropItemWindows.SearchItem=DropSearch + uiDropItem.DropItemWindows.BINARY_DROP_ITEM_LOADING=DropReady + uiDropItem.DropItemWindows.NativeQueryFailed=DropFailed + def DropLoad(self): + _dropLoad(self) + self.GetChild('TitleName').SetText(L('掉落查询')) + self.ButtonSearch.SetToolTipText(L('查询掉落来源')) + self.ButtonDelete.SetToolTipText(L('清空查询')) + def DropInfo(self): + _dropInfo(self) + for index in xrange(min(self.pages_view,max(0,self.total_dates-(self.page_actual-1)*self.pages_view))): + row=index+(self.page_actual-1)*self.pages_view + self.ButtonsSelect['Cantidad_Item_%d'%index].SetText(L('数量:%d')%self.FReturnInfo('count_item',row)) + self.TotalResultados.SetText(L('共 %d 条')%max(0,self.total_dates)) + uiDropItem.DropItemWindows.LoadWindow=DropLoad + uiDropItem.DropItemWindows.LoadInfo=DropInfo +except Exception:pass # The classic text renderer has no AVA2 inline-emoji markup. Preserve the list bullet # in the native wiki's two text builders rather than exposing markup to the player. diff --git a/src/platform/ScriptLib/CostumeAttrScript.inc b/src/platform/ScriptLib/CostumeAttrScript.inc index a591409e..4210d798 100644 --- a/src/platform/ScriptLib/CostumeAttrScript.inc +++ b/src/platform/ScriptLib/CostumeAttrScript.inc @@ -16,7 +16,9 @@ L=player.AutoHuntLocalize VNUMS=(54001,54267) MAX_ATTR=3 # AVA2 CItem::GetBonusFlag of the costume kinds the server maps -> (mask bit, target name). -TARGETS={item.COSTUME_TYPE_BODY:(1,'时装'),item.COSTUME_TYPE_HAIR:(2,'发型'),item.COSTUME_TYPE_MOUNT_SKIN:(4,'坐骑外观')} +TARGETS={item.COSTUME_TYPE_BODY:(1,'时装'),item.COSTUME_TYPE_HAIR:(2,'发型'), + getattr(item,'COSTUME_TYPE_WEAPON',5):(3,'武器外观'),item.COSTUME_TYPE_MOUNT_SKIN:(4,'坐骑外观'), + getattr(item,'COSTUME_TYPE_NEW_SASH',6):(5,'披风外观')} MESSAGES={'target':'该强化石不能用于这件物品。','none':'该强化石没有可附加的属性。','equipped':'请先卸下时装再附加属性。', 'full':'这件时装的附加属性已满(最多 3 条)。','has':'这件时装已有该属性。','done':'附加属性成功。'} @@ -33,8 +35,10 @@ def CanEnchant(enchant,dstSlot): dstVnum=player.GetItemIndex(dstSlot) if not dstVnum or player.IsEquipmentSlot(dstSlot):return False item.SelectItem(dstVnum) - if item.GetItemType()!=item.ITEM_TYPE_COSTUME:return False - target=TARGETS.get(item.GetItemSubType()) + iType=item.GetItemType() + if iType==item.ITEM_TYPE_COSTUME:target=TARGETS.get(item.GetItemSubType()) + elif iType==getattr(item,'ITEM_TYPE_SHINING',35):target=(6,'特效') + else:return False if not target or not enchant[2]&(1<= c_Costume_Slot_Start) - if (iSlotIndex <= c_Costume_Slot_End) + if (iSlotIndex == c_Costume_Slot_Body || + iSlotIndex == c_Costume_Slot_Hair || + iSlotIndex == c_Costume_Slot_Sash || + iSlotIndex == c_Costume_Slot_Mount || + iSlotIndex == c_Costume_Slot_MountSkin || + iSlotIndex == c_Costume_Slot_Weapon || + iSlotIndex == c_Costume_Slot_Pet || + iSlotIndex == c_Costume_Slot_NewSash || + iSlotIndex == c_Shining_Slot_Weapon || + iSlotIndex == c_Shining_Slot_Armor || + iSlotIndex == c_Shining_Slot_Special) + { return Py_BuildValue("i", 1); + } #endif return Py_BuildValue("i", 0); @@ -2728,6 +2739,19 @@ void initPlayer() PyModule_AddIntConstant(poModule, "AUTO_POTION_TYPE_HP", CPythonPlayer::AUTO_POTION_TYPE_HP); PyModule_AddIntConstant(poModule, "AUTO_POTION_TYPE_SP", CPythonPlayer::AUTO_POTION_TYPE_SP); + // AVA2 Costume Slots + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_BODY", c_Costume_Slot_Body); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_HAIR", c_Costume_Slot_Hair); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_SASH", c_Costume_Slot_Sash); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_MOUNT", c_Costume_Slot_Mount); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_MOUNT_SKIN", c_Costume_Slot_MountSkin); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_WEAPON", c_Costume_Slot_Weapon); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_PET", c_Costume_Slot_Pet); + PyModule_AddIntConstant(poModule, "COSTUME_SLOT_NEW_SASH", c_Costume_Slot_NewSash); + PyModule_AddIntConstant(poModule, "SHINING_SLOT_WEAPON", c_Shining_Slot_Weapon); + PyModule_AddIntConstant(poModule, "SHINING_SLOT_ARMOR", c_Shining_Slot_Armor); + PyModule_AddIntConstant(poModule, "SHINING_SLOT_SPECIAL", c_Shining_Slot_Special); + // 용혼석 PyModule_AddIntConstant(poModule, "DRAGON_SOUL_PAGE_SIZE", c_DragonSoul_Inventory_Box_Size); PyModule_AddIntConstant(poModule, "DRAGON_SOUL_PAGE_COUNT", DRAGON_SOUL_GRADE_MAX); diff --git a/tests/port/port_python_ui_modules_test.cpp b/tests/port/port_python_ui_modules_test.cpp index e5f8f301..06a0745f 100644 --- a/tests/port/port_python_ui_modules_test.cpp +++ b/tests/port/port_python_ui_modules_test.cpp @@ -4,6 +4,8 @@ #include "UserInterface/StdAfx.h" extern void initapp(); extern void initPlayer(); +extern void initItem(); +extern void initchrmgr(); #include "UserInterface/PythonPlayer.h" #include #include "../../src/platform/ScriptLib/PythonHost.h" @@ -32,13 +34,15 @@ int main(int argc, char** argv) initgrpThing(); initwndMgr(); initapp(); + initItem(); + initchrmgr(); CPythonPlayer player; initPlayer(); CPythonPlayer::Instance().SetGold64(123456789012345LL); assert(CPythonPlayer::Instance().GetGold64() == 123456789012345LL); assert(CPythonPlayer::Instance().GetStatus(POINT_GOLD) == 2000000000); if (!launcher.RunLine( - "import player\n" + "import player, item, chrmgr\n" "gold = player.GetElk()\n" "assert gold == 123456789012345L, 'GetElk mismatch: %r' % gold\n" "assert player.GetGold64() == 123456789012345L\n" @@ -49,6 +53,21 @@ int main(int argc, char** argv) "assert _fmt(gold) == '123.46 T'\n" "assert _fmt(5200000000L) == '5.20 B'\n" "assert _fmt(1234567) == '1,234,567'\n" + "assert item.COSTUME_SLOT_WEAPON == player.COSTUME_SLOT_WEAPON\n" + "assert item.COSTUME_SLOT_NEW_SASH == player.COSTUME_SLOT_NEW_SASH\n" + "assert item.SHINING_SLOT_WEAPON == player.SHINING_SLOT_WEAPON\n" + "assert item.SHINING_SLOT_ARMOR == player.SHINING_SLOT_ARMOR\n" + "assert item.SHINING_SLOT_SPECIAL == player.SHINING_SLOT_SPECIAL\n" + "assert player.IsCostumeSlot(player.COSTUME_SLOT_WEAPON) == 1\n" + "assert player.IsCostumeSlot(player.COSTUME_SLOT_NEW_SASH) == 1\n" + "assert player.IsCostumeSlot(player.SHINING_SLOT_WEAPON) == 1\n" + "assert player.IsCostumeSlot(player.SHINING_SLOT_ARMOR) == 1\n" + "assert player.IsCostumeSlot(player.SHINING_SLOT_SPECIAL) == 1\n" + "assert item.COSTUME_TYPE_WEAPON == 5\n" + "assert item.COSTUME_TYPE_NEW_SASH == 6\n" + "assert item.ITEM_TYPE_SHINING == 35\n" + "assert item.SHINING_WEAPON == 0\n" + "assert chrmgr.EFFECT_SHINING_WEAPON >= 0\n" )) return 1; if (!launcher.RunLine("import wndMgr, grp, grpImage, grpText, grpThing, app"))