一.事件
游戏中大地图遭遇,显示国家信息,显示金钱信息等等都被称为游戏事件,游戏事件可通过重写module_scripts.py中的脚本实现对应功能,比如修改遇到军队后的弹框,武器详情显示等等,系统提供的相关API有:
#角色详情页
game_character_screen_requested
#武器装备名称显示
game_get_item_extra_text
#场景物scene_prop使用(箱子,投石车)
game_get_use_string
#人物/国家/城镇/兵种列表信息
game_get_quest_note
game_get_faction_note
game_get_center_note
game_get_troop_note
#金钱显示
game_get_money_text
#日期显示
game_get_date_text
#大地图遭遇到军队
game_event_party_encounter
#游戏初始化国家,势力
game_start
#发射炮弹
game_missile_dives_into_water
game_missile_launch
game_troop_upgrades_button_clicked
game_multiplayer_event_duel_offered
game_get_cheat_mode
game_receive_url_response
game_get_multiplayer_game_type_enum
game_multiplayer_get_game_type_mission_template
game_get_morale_of_troops_from_faction
game_get_upgrade_cost
game_get_upgrade_xp
game_multiplayer_server_option_for_mission_template_to_string
game_get_multiplayer_server_option_for_mission_template
game_receive_network_message
game_get_mission_template_name
game_get_scene_name
game_get_info_page_note
game_event_battle_end
game_get_party_speed_multiplier
game_check_party_sees_party
game_reset_player_party_name
game_get_skill_modifier_for_troop
game_event_context_menu_button_clicked
game_context_menu_get_buttons
game_on_disembark
game_get_party_prisoner_limit
game_get_party_companion_limit
game_get_statistics_line
game_event_undetect_party
game_event_detect_party
game_check_prisoner_can_be_sold
game_get_prisoner_price
game_get_join_cost
game_get_total_wage
game_get_troop_wage
game_event_sell_item
game_event_buy_item
game_get_item_sell_price_factor
game_get_item_buy_price_factor
game_event_simulate_battle
game_enable_cheat_menu
game_get_console_command
game_set_multiplayer_mission_end
game_quick_start
二.屏幕
骑砍屏幕3D渲染分为大地图模型加载和游戏场景模型加载,系统屏幕的切换通过change_screen相关API进行。
# Game hardcoded windows and related operations
change_screen_return = 2040 # (change_screen_return),
# Closes any current screen and returns the player to world map. In missions nothing happens.
#NPC交换装备/宝箱交换装备
change_screen_loot = 2041 # (change_screen_loot, ),
# Opens the Looting interface, using the provided troop as loot storage. Player has full access to troop inventory.
change_screen_trade = 2042 # (change_screen_trade, [troop_id]),
# Opens the Trade screen, using the provided troop as the trading partner. When called from module_dialogs, troop_id is optional and defaults to current dialogue partner.
change_screen_exchange_members = 2043 # (change_screen_exchange_members, [exchange_leader], [party_id]),
# Opens the Exchange Members With Party interface, using the specified party_id. If called during an encounter, party_id is optional and defaults to the encountered party. Second parameter determines whether the party leader [0, 1] is exchangeable (useful when managing the castle garrison).
change_screen_trade_prisoners = 2044 # (change_screen_trade_prisoners),
# Opens the Sell Prisoners interface. Script "script_game_get_prisoner_price" will be used to determine prisoner price.
change_screen_buy_mercenaries = 2045 # (change_screen_buy_mercenaries),
# Opens the Buy Mercenaries interface, where player can hire troops from the party specified with (set_mercenary_source_party) operation. Only works from the dialog.
##查看对应NPC属性 力量/敏捷/智力/魅力
change_screen_view_character = 2046 # (change_screen_view_character),
# Opens the character screen of another troop. Can only be used in dialogs.
change_screen_training = 2047 # (change_screen_training),
# Opens the character screen for the troop that player is currently talking to. Only works in dialogs. Deprecated, use (change_screen_view_character) instead.
change_screen_mission = 2048 # (change_screen_mission),
# Starts the mission, using previously defined scene and mission template.
change_screen_map_conversation = 2049 # (change_screen_map_conversation, ),
# Starts the mission, same as (change_screen_mission). However once the mission starts, player will get into dialog with the specified troop, and once the dialog ends, the mission will automatically end.
change_screen_exchange_with_party = 2050 # (change_screen_exchange_with_party, ),
# Effectively duplicates (change_screen_exchange_members), but party_id parameter is obligatory and the operation doesn't have an option to prevent party leader from being exchanged.
change_screen_equip_other = 2051 # (change_screen_equip_other, [troop_id]),
# Opens the Equip Companion interface. When calling from a dialog, it is not necessary to specify troop_id.
change_screen_map = 2052 # (change_screen_map),
# Changes the screen to global map, closing any currently running game menu, dialog or mission.
change_screen_notes = 2053 # (change_screen_notes, , ),
# Opens the Notes screen, in the selected category (note_type: 1=troops, 2=factions, 3=parties, 4=quests, 5=info_pages) and for the specified object in that category.
change_screen_quit = 2055 # (change_screen_quit),
# Quits the game to the main menu. Most probably needs to be called from module_game_menus.
change_screen_give_members = 2056 # (change_screen_give_members, [party_id]),
# Opens the Give Troops to Another Party interface. Party_id parameter is optional during an encounter and will use encountered party as default value.
change_screen_controls = 2057 # (change_screen_controls),
# Opens the standard Configure Controls screen, pausing the game.
change_screen_options = 2058 # (change_screen_options),
# Opens the standard Game Options screen, pausing the game.
菜单页跳转至场景:
(set_jump_mission,"mt_tutorial_training_ground"),
(jump_to_scene,"scn_tutorial_training_ground"),
(change_screen_mission),
对话框跳转至场景:
[anyone|plyr,"arena_master_melee_talk", [], "Good. That's what I am going to do.", "close_window",
[
(assign, "$last_training_fight_town", "$current_town"),
(store_current_hours,"$training_fight_time"),
(assign, "$g_mt_mode", abm_training),
(party_get_slot, ":scene","$current_town",slot_town_arena),
(modify_visitors_at_site,":scene"),
(reset_visitors),
(store_random_in_range, "$g_player_entry_point", 32, 40),
(set_visitor, "$g_player_entry_point", "trp_player"),
(set_jump_mission,"mt_arena_melee_fight"),
(jump_to_scene, ":scene"),
]],
场景跳转至场景:
(assign, "$last_training_fight_town", "$current_town"),
(store_current_hours,"$training_fight_time"),
(assign, "$g_mt_mode", abm_training),
(party_get_slot, ":scene","$current_town",slot_town_arena),
(modify_visitors_at_site,":scene"),
(reset_visitors),
(store_random_in_range, "$g_player_entry_point", 32, 40),
(set_visitor, "$g_player_entry_point", "trp_player"),
(set_jump_mission,"mt_arena_melee_fight"),
(jump_to_scene, ":scene"),
大地图跳转至场景:
(modify_visitors_at_site,"scn_rz_case"),
(reset_visitors),
(set_visitor, 0, "trp_player"),
(set_visitor, 6, "trp_swadian_sergeant"),
(set_visitor, 7, "trp_swadian_sergeant"),
(set_visitor, 27, "trp_kingdom_1_lord"),
(set_visitor, 28, "trp_kingdom_1_lord"),
(set_jump_mission, "mt_rz_case"),
(jump_to_scene, "scn_rz_case"),
(change_screen_mission),
(start_presentation, "prsnt_game_credits"),
(presentation_set_duration, 0),
三.菜单&对话框(menu&dialog)
<1.module_menu.py提供菜单的列表,系统预制菜单如下:
start_game_0 开始新游戏加载的菜单,index为0
start_phase_2 完成角色皮肤后加载的菜单,index为1
开始新游戏加载菜单:
("start_game_0",menu_text_color(0xFF000000)|mnf_disable_all_keys,
"Welcome, adventurer, to Mount and Blade: Warband.",
"none",
[],
[
("continue",[],"Continue...",
[
(jump_to_menu, "mnu_start_game_0"),
(change_screen_give_members, "p_town_1"),
(change_screen_equip_other, "trp_npc1"),
]
),
("go_back",[],"Go back",
[
(change_screen_quit),
]),
]
),
菜单跳转:
(jump_to_menu, "mnu_start_game_0"),
<2.module_dialog.py提供对话框的列表:对话框弹出回调状态:
#系统预制状态
"start": 在大地图或者城镇遇到某人或某个军团
"party_relieved": 在大地图上协助某个军团战投时弹出
"prisoner_liberated": 在队伍里释放某个俘虏
"enemy_defeated": 当击败某个队伍时
"event_triggered": 当某个触发器触发时,如调用代码start_map_conversation
#在mission或map中开启对话API
(start_map_conversation,),
(change_screen_map_conversation, ),
(start_mission_conversation, ),
#弓箭大师对话
[trp_tutorial_master_archer, "start",
[
(try_begin),
(eq, "$g_tutorial_training_ground_intro_message_being_displayed", 1),
(assign, "$g_tutorial_training_ground_intro_message_being_displayed", 0),
(tutorial_message, -1), #remove tutorial intro immediately before a conversation
(try_end),
],
"Good day to you, young fellow. I spend my days teaching about ranged weapons to anyone that is willing to learn.\
If you need a tutor, let me know and I'll teach you how to use the bow, the crossbow and the javelin.", "archer_talk",
[]],
[anyone|plyr, "archer_talk",
[
(eq, "$g_tutorial_training_ground_archer_trainer_completed_chapters", 0),
],
"Yes, show me how to use ranged weapons.", "archer_challenge", []],
四.界面(presentation)
由module_presentation.py提供展示列表,如游戏中载入游戏,角色详情页都是由presentation.py提供.可重写系统固化的presentation实现界面变化.
系统预制presentation:
prsnt_game_custom_battle_designer 常规战斗选项页
prsnt_game_profile_banner_selection 选择旗帜页
prsnt_game_multiplayer_admin_panel
prsnt_game_before_quit
prsnt_game_credits 游戏鸣谢详情页
prsnt_game_escape
prsnt_game_start 游戏主界面
presentation触发器:
ti_on_presentation_load 2D界面首次加载时触发
ti_on_presentation_run 2D界面每一帧渲染时触发
ti_on_presentation_event_state_change 文本框输入框等事件触发
ti_on_presentation_mouse_press 鼠标点击事件
ti_on_presentation_mouse_enter 鼠标进入事件
presentation开启&打开:
(start_presentation, ),
(presentation_set_duration, ),
常规战斗界面:
("game_custom_battle_designer", prsntf_manual_end_only, mesh_cb_ui_main, [
(ti_on_presentation_load,[]),
(ti_on_presentation_event_state_change,[]),
(ti_on_presentation_mouse_enter_leave,[]),
(ti_on_presentation_run,[]),
]),
五.3D投影至2D(overlay&mesh&tableau_material)
通过create_mesh_overlay实现3D模型的2D投影,3D模型投影参数和配置在module_meshes.py控制,投影时光照,材质通过module_tableau_materials.py控制,可控制透明度和遮罩等高级渲染功能.
创建overlay-API:
create_mesh_overlay = 911 # (create_mesh_overlay, , ),
create_mesh_overlay_with_item_id = 944 # (create_mesh_overlay_with_item_id, , ),
create_mesh_overlay_with_tableau_material = 939 # (create_mesh_overlay_with_tableau_material, , , , ),
添加BRF资源至module_mesh.py中
meshes = [
("pic_bandits", 0, "pic_bandits", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_mb_warrior_1", 0, "pic_mb_warrior_1", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_messenger", 0, "pic_messenger", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_prisoner_man", 0, "pic_prisoner_man", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_prisoner_fem", 0, "pic_prisoner_fem", 0, 0, 0, 0, 0, 0, 1, 1, 1),
("pic_prisoner_wilderness", 0, "pic_prisoner_wilderness", 0, 0, 0, 0, 0, 0, 1, 1, 1),
module_tableau_materials.py设置环境光照.alpha渲染参数等:
# Operations used in module_tableau_materials.py module
cur_tableau_add_tableau_mesh = 1980 # (cur_tableau_add_tableau_mesh,, , ),
cur_tableau_render_as_alpha_mask = 1984 # (cur_tableau_render_as_alpha_mask)
cur_tableau_set_background_color = 1985 # (cur_tableau_set_background_color, ),
cur_tableau_set_ambient_light = 1987 # (cur_tableau_set_ambient_light, , , ),
cur_tableau_set_camera_position = 1988 # (cur_tableau_set_camera_position, ),
cur_tableau_set_camera_parameters = 1989 # (cur_tableau_set_camera_parameters, , , , , ),
cur_tableau_add_point_light = 1990 # (cur_tableau_add_point_light, , , , ),
cur_tableau_add_sun_light = 1991 # (cur_tableau_add_sun_light, , , , ),
cur_tableau_add_mesh = 1992 # (cur_tableau_add_mesh, , , , ),
cur_tableau_add_mesh_with_vertex_color = 1993 # (cur_tableau_add_mesh_with_vertex_color, , , , , ),
cur_tableau_add_mesh_with_scale_and_vertex_color = 2000 # (cur_tableau_add_mesh_with_scale_and_vertex_color, , , , , ),
cur_tableau_add_map_icon = 1994 # (cur_tableau_add_map_icon, , , ),
cur_tableau_add_troop = 1995 # (cur_tableau_add_troop, , , , ),
cur_tableau_add_horse = 1996 # (cur_tableau_add_horse, , , ),
cur_tableau_set_override_flags = 1997 # (cur_tableau_set_override_flags, ),
cur_tableau_clear_override_items = 1998 # (cur_tableau_clear_override_items),
cur_tableau_add_override_item = 1999 # (cur_tableau_add_override_item, ),
引擎定制mesh.
#游戏加载背景图
mesh_loading_background
#弓箭弹药状态
mesh_status_ammo_ready
引擎定制tableau_material材质.
#游戏窗口
tab_game_profile_window
#军旗
tab_game_troop_label_banner
#部队详情页
tab_game_party_window
#个人仓库页
tab_game_inventory_window
#角色详情页
tab_game_character_sheet