本帖最后由 奥杜因阿卡托什 于 2023-4-30 00:29 编辑
自打从老彼得处知道了怎么修改大地图界面底下一排按键的跳转,我就摩拳擦掌地准备做新界面了。断断续续做了几个星期,基本上把物品栏磨了出来。
看一下效果,鼠标滑过之后会把指向的槽高亮(原理其实是有一张不亮的图一张亮的图,把不亮的放在亮的上层,鼠标放在它上面就把两张图的上下关系反过来),鼠标移开高亮就会消失。点击框之后能把框点亮,表示选中。接下来能点亮的框只能是能与该位置互换物品的框(比如如果点亮了右手武器,那第二个点亮的可以是右手武器其他两个框和右边的备选物品,其他种类的装备框无法点亮),点亮两个以后按“交换所选物品”就能交换位置,将物品装卸和移动。除此之外还有快捷键,在没有任何物品被点亮的情况下按住左ctrl,点击物品框能把已经装备的武器直接卸下,也能直接装备未装备的物品。不管已经点亮的框有多少,点击任何里面有物品的框都会把中间的显示切换成这个物品。
可以看到我这个物品栏左右手一共有六个装备槽,其中左手能装备盾和弓,右手装备剩余武器,箭矢弹药有两个专门的槽位,不会占用两手位置。底下的饰品是加属性特效的,小道具是按R能使用的,快速补给预计会用来装一些应急食品、绷带、纳米机器人修补液之类的,按H能给人、马或者盾加血。战场上左右手切换六种武器的代码已经实现了,下面会一并放出。
首先说说物品栏的代码,首先需要定义一系列的constant,在AGENT名下,分别是
slot_agent_weapon_1 = 41
slot_agent_weapon_2 = 42
slot_agent_weapon_3 = 43
slot_agent_weapon_4 = 44
slot_agent_weapon_5 = 45
slot_agent_weapon_6 = 46
slot_agent_weapon_ammo_1 = 47
slot_agent_weapon_ammo_2 = 48
slot_agent_weapon_ammo_3 = 49
slot_agent_shield_hp_1 = 50
slot_agent_shield_hp_2 = 51
slot_agent_shield_hp_3 = 52 |
然后是从大地图上点物品栏的跳转,原理详见https://bbs.mountblade.com.cn/thread-2094106-1-1.html。我这里就直接放出代码了,加在simple_trigger里
#map buttons
(0.000000,
[
(set_fixed_point_multiplier, 1000),
(mouse_get_position, pos1),
(position_get_x, ":cur_x", pos1),
(position_get_y, ":cur_y", pos1),
(try_begin),
(key_clicked, key_left_mouse_button),
(try_begin),
(is_between, ":cur_x", 440, 550),#inventory
(is_between, ":cur_y", 0, 40),
(start_presentation, "prsnt_inventory_new"),
(try_end),
(try_end),
]), |
然后是两个新troop,这两个的作用是扩充玩家背包,纯纯工具人。
# Chests
["player_additional_inventory_1","{!}Fiend Chest1","{!}Fiend Chest1",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_assault_helmet],def_attrib|level(18),wp(60),knows_common|knows_inventory_management_10, 0],
["player_additional_inventory_2","{!}Fiend Chest1","{!}Fiend Chest1",tf_hero|tf_inactive, 0,reserved, fac_neutral,[itm_assault_helmet],def_attrib|level(18),wp(60),knows_common|knows_inventory_management_10, 0], |
接下来就是重头戏的两个压缩包,一个是presentation一个是script,不过这两个可以丢到MS里即打即用的。丢进MS里以后,只需要在script和presentation里申明一下即可
在script的最开头加上from module_scripts_inventory import *
在script的最结尾加上scripts = scripts + inventory_scripts
在presentation的最开头加上from module_presentations_inventory import *
在presentation的最结尾加上presentations = presentations + inventory_presentations
注意这个开头结尾是真的开头结尾,[ ]之外。 |
然后还有调用到的mesh和string,mesh里面的模型名就自己按自己的模型填吧。
("inventory_highlight", 0, "inventory_highlight", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_accessory", 0, "inventory_accessory", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_small_prop", 0, "inventory_small_prop", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_foot", 0, "inventory_foot", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_body", 0, "inventory_body", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_hand", 0, "inventory_hand", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_empty_slot", 0, "inventory_empty_slot", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_head", 0, "inventory_head", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_ammo", 0, "inventory_ammo", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_left_hand", 0, "inventory_left_hand", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("inventory_right_hand", 0, "inventory_right_hand", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("mp_ui_host_main", 0, "mp_ui_host_main", 0, 0, 0, 0, 0, 0, 1, 1, 1),
用到的图片模型什么的我就懒得放出了。 |
("one_line_text", "{s1}"),
("two_line_text", "{s1}^{s2}"),
("three_line_text", "{s1}^{s2}^{s3}"),
("four_line_text", "{s1}^{s2}^{s3}^{s4}"),
("fire_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}"),
("six_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}^{s6}"),
("seven_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}^{s6}^{s7}"),
("eight_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}^{s6}^{s7}^{s8}"),
("nine_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}^{s6}^{s7}^{s8}^{s9}"),
("ten_line_text", "{s1}^{s2}^{s3}^{s4}^{s5}^{s6}^{s7}^{s8}^{s9}^{s10}"),
("right_hand", "right_hand"),
("left_hand", "left_hand"),
("armor", "armor"),
("horse", "horse"),
("ammo", "ammo"),
("accessory", "accessory"),
("small_tool", "small_tool"),
("supply", "supply"),
("strength", "strength"),
("agility", "agility"),
("intelligence", "intelligence"),
("charisma", "charisma"),
("ironflesh", "ironflesh"),
("power_strike", "power_strike"),
("power_throw", "power_throw"),
("power_draw", "power_draw"),
("riding", "riding"),
("shield", "shield"),
("wpt_one_handed", "one_handed"),
("wpt_two_handed", "two_handed"),
("wpt_polearm", "polearm"),
("wpt_archery", "archery"),
("wpt_crossbow", "crossbow"),
("wpt_throwing", "throwing"),
("mount", "mount"),
("one_handed_wpn", "one_handed_wpn"),
("two_handed_wpn", "two_handed_wpn"),
("polearm", "polearm"),
("arrows", "arrows"),
("bolts", "bolts"),
("shield", "shield"),
("bow", "bow"),
("crossbow", "crossbow"),
("thrown", "thrown"),
("goods", "goods"),
("head_armor", "head_armor"),
("body_armor", "body_armor"),
("foot_armor", "foot_armor"),
("hand_armor", "hand_armor"),
("pistol", "pistol"),
("musket", "musket"),
("bullets", "bullets"),
("animal", "animal"),
("book", "book"),
("shield_protection", "shield_protection"),
("horse_protection", "horse_protection"),
("body_protection", "body_protection"),
("shield_hp", "shield_hp"),
("horse_hp", "horse_hp"),
("close_combat_thrust_damage", "close_combat_thrust_damage"),
("ranged_weapon_damage", "ranged_weapon_damage"),
("throw_damage", "throw_damage"),
("cut", "cut"),
("stab", "stab"),
("knock", "knock"),
("cannot_equip", "cannot_equip"),
("get_weight", "{reg1}.{reg2} kg"),
("get_difficulty", "{reg1} Difficulty {s1}"),
("get_head_armor", "{reg1} head armor"),
("get_body_armor", "{reg1} body armor {s1}"),
("get_leg_armor", "{reg1} leg armor {s1}"),
("get_hit_points", "{reg1} points {s1}"),
("get_shield_length", "{reg1} cm"),
("get_weapon_length", "{reg1} cm"),
("get_speed_rating", "{reg1} {s1}"),
("get_missile_speed", "{reg1} Km/h {s1}"),
("get_max_ammo_load", "{reg1}"),
("get_max_ammo", "{reg1}"),
("get_good_amount", "{reg1}"),
("get_accuracy", "{reg1} percent"),
("get_horse_scale", "{reg1}.{reg2} cm tall"),
("get_horse_speed", "{reg1} kms"),
("get_horse_maneuver", "{reg1}"),
("get_food_quality", "{reg1} portion"),
("get_abundance", "{reg1}"),
("get_thrust_damage", "{reg1} thrust {s1}{s2}"),
("get_ammo_damage_increase", "get_ammo_damage_increase{reg1}"),
("get_swing_damage", "{reg1} swing"),
("get_horse_charge_damage", "{reg1} charge"),
("penetrate_shield", "penetrate_shield"),
("bonus_against_shield", "bonus_against_shield"),
("next_item_as_melee", "next_item_as_melee"),
("couchable", "couchable"),
("crush_through", "crush_through"),
("can_knock_down", "can_knock_down"),
("extra_penetration", "extra_penetration"),
这么直接塞进去当然是没有汉化的。 |
如果我没漏掉什么东西的话,以上就是物品栏整个的内容了。接下来说说拔出六把武器的代码,主要是几个触发器。
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param, ":agent_no", 1),
(agent_is_human, ":agent_no"),
(agent_is_alive, ":agent_no"),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(ge, ":troop_no", 0),
(troop_is_hero, ":troop_no"),
(eq, ":troop_no", "trp_player"),
(assign, "$mission_player_agent", ":agent_no"),
(assign, "$cur_weapon_right_hand", 40),
(assign, "$cur_weapon_left_hand", 43),
(try_for_range, ":inventory_slot_no", 10, 16),
(troop_get_inventory_slot, ":weapon_no", ":troop_no", ":inventory_slot_no"),
(store_add, ":inventory_modifier_slot_no", ":inventory_slot_no", 1201),
(troop_get_slot, ":modifier_no", ":troop_no", ":inventory_modifier_slot_no"),
(store_add, ":slot_no", ":inventory_slot_no", 31),
(agent_set_slot, ":agent_no", ":slot_no", ":weapon_no"),#item_kind
(val_add, ":slot_no", 10),
(agent_set_slot, ":agent_no", ":slot_no", ":modifier_no"),#modifier
(try_end),
(try_for_range, ":inventory_slot_no", 10, 13),
(troop_get_inventory_slot, ":weapon_no", ":troop_no", ":inventory_slot_no"),
(gt, ":weapon_no", 0),
(item_get_max_ammo, ":ammo_num", ":weapon_no"),
(store_add, ":slot_no", ":inventory_slot_no", 37),
(agent_set_slot, "$mission_player_agent", ":slot_no", ":ammo_num"),
(try_end),
(try_for_range, ":inventory_slot_no", 13, 16),
(troop_get_inventory_slot, ":weapon_no", ":troop_no", ":inventory_slot_no"),
(gt, ":weapon_no", 0),
(item_get_hit_points, ":shield_hp", ":weapon_no"),
(store_add, ":slot_no", ":inventory_slot_no", 37),
(agent_set_slot, "$mission_player_agent", ":slot_no", ":shield_hp"),
(try_end),
]),
(0, 0, 0, [
(key_clicked, key_mouse_scroll_up),],
[
(assign, "$change_weapon_try_time", 0),
(call_script, "script_right_hand_get_next_usable_weapon"),
(try_begin),
(gt, reg1, 0),
(agent_equip_item, "$mission_player_agent", reg1, 1),
(agent_set_wielded_item, "$mission_player_agent", reg1),
(store_add, ":slot_no", "$cur_weapon_right_hand", 6),
(agent_get_slot, ":ammo_num", "$mission_player_agent", ":slot_no"),
(agent_set_ammo, "$mission_player_agent", reg1, ":ammo_num"),
(try_end),
(assign, "$change_weapon_try_time", 0),
]),
(0, 0, 0, [
(key_clicked, key_mouse_scroll_down),],
[
(assign, "$change_weapon_try_time", 0),
(call_script, "script_left_hand_get_next_usable_weapon"),
(try_begin),
(gt, reg1, 0),
(agent_equip_item, "$mission_player_agent", reg1, 2),
(agent_set_wielded_item, "$mission_player_agent", reg1),
(try_end),
(assign, "$change_weapon_try_time", 0),
]), |
自己加到各个mission里即可。至于效果,和正常的滚轮切换武器差不多,往上转切换右手武器,往下转切换左手武器。
由于物品栏内部的逻辑判断和迷宫一样复杂,条件与特例太多了,我也不能保证我这个能完全接管原有的物品栏。目前我这里还原了切换武器保留上弹数、食物消耗、按X键切换模式的投掷武器的展示,如果汽油们还能想到什么需要特殊处理的物品,或者使用时发现了什么问题,请尽量告知我,我这边也好改进。另外目前切换左手武器盾值会刷新,这个我这里是已经解决了,但是解决方法比较鬼畜,以后可能还要单开一贴讲。另外如果在战场上丢弃、拾捡武器,会发现转一转滚轮之前武器又出来了。武器丢弃拾起这块因为还没有做,不过反正就是ti_on_item_dropped和ti_on_item_picked_up两个trigger,有兴趣的可以自己弄弄看。
最大问题是物品前缀。我因为是打算把物品前缀系统用自己的方法整个重做了,所以原有的前缀就每太去管它。导致更换武器的话会把有前缀的武器刷成白板。代码里所有出现modifier的地方都是我给之后会做的新前缀系统留的接口。
更新:
最近发现一个bug,不知道还有没有别人发现。那就是在如果玩家有战团那种纹章可换的盾牌衣服,物品栏会出现严重错位。这个其实不是逻辑错误,今天研究了一下后发现,把物品的贴图生成出来也会触发获取纹章的init触发器,而这个触发器中用到了一个tableau,这个tableau的第一行就是个设置: (set_fixed_point_multiplier, 100),也就是说,它把分辨率改了。
要解决这个问题也不难,只要在所有可能调用到它的地方后面再把分辨率设置回1000就行了。在所有文件中搜索“with_item_id”(有三处),紧跟着它写上 (set_fixed_point_multiplier, 1000),记得要紧跟着,因为这个后面往往就是设置坐标了,要是等坐标设置完再调整分辨率那为时已晚。
|