Skrypt na uderzenie tarczą by xenoargh, nowa deweloperska wersja by Sinisterius (wersja od Mirathei już nie działa, więc dodałem tą)Dzięki temu skryptowi my, wrogowie i nasi wojacy będą mogli uderzać tarczą i powalić bądź ogłuszyć przeciwnika.
Na początku przechodzimy do module_mission_templates.py. Szukamy tych linijek:
pilgrim_disguise = [itm_pilgrim_hood,itm_pilgrim_disguise,itm_practice_staff, itm_throwing_daggers]
af_castle_lord = af_override_horse | af_override_weapons| af_require_civilian
Pod tymi linijkami wklejamy ten kod:
################################################
## Shield Bash ##
## Developed by 'xenoargh' for singleplayer. ##
## Revamped by 'Sinisterius'. ##
## Animations Copyright (C) 2010 'xenoargh'. ##
################################################
#####
#Add these following triggers to module_mission_templates.py,
#above all other code. Then simply add:
#sp_shield_bash_1,
#sp_shield_bash_2,
#sp_shield_bash_3,
#To your mission templates to activate the triggers.
sp_shield_bash_1 = (
0, 0, 0,
[
(eq, "$sp_shield_bash", 1),
(game_key_is_down, gk_defend),
(game_key_clicked, gk_attack),
],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_defend_action, ":action", ":agent"),
(eq, ":action", 2), #Blocking.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, 5),
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 150),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(neg|agent_is_ally, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
])
sp_shield_bash_2 = (
1, 0, 0, [(eq, "$sp_shield_bash", 1)],
[
(get_player_agent_no, ":agent"),
(agent_is_active, ":agent"),
(agent_is_alive, ":agent"),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
])
sp_shield_bash_3 = (
0.25, 0, 0, [(eq, "$sp_shield_bash_ai", 1)],
[
(get_player_agent_no, ":player_agent"),
(try_for_agents, ":agent"),
(neq, ":agent", ":player_agent"),
(agent_is_alive, ":agent"),
(agent_is_human, ":agent"),
(try_begin),
(neg|agent_slot_ge, ":agent", sp_agent_shield_bash_timer, 1), #Less than.
(agent_slot_eq, ":agent", slot_agent_is_running_away, 0), #Isn't routing.
(agent_get_wielded_item, ":item", ":agent", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield), #Shield equipped.
(agent_get_attack_action, ":action", ":agent"),
(eq, ":action", 0), #Free.
(agent_get_horse, ":horse", ":agent"),
(eq, ":horse", -1), #No horse.
(agent_get_team, ":team", ":agent"),
(agent_get_position, pos1, ":agent"),
(assign, ":victim", -1),
(assign, ":minimum_distance", 125),
(try_for_agents, ":suspect"),
(agent_is_alive, ":suspect"),
(agent_is_human, ":suspect"),
(agent_get_position, pos2, ":suspect"),
(neg|position_is_behind_position, pos2, pos1), #Suspect can't be behind basher.
(agent_get_team, ":suspect_team", ":suspect"),
(neq, ":suspect_team", ":team"),
(get_distance_between_positions, ":distance", pos1, pos2),
(le, ":distance", ":minimum_distance"),
(assign, ":minimum_distance", ":distance"),
(assign, ":victim", ":suspect"),
(try_end),
(ge, ":victim", 0),
(agent_get_horse, ":horse", ":victim"),
(eq, ":horse", -1),
(store_random_in_range, ":rand", 15, 26),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":rand"), #20 is 20*0.25=5seconds.
(agent_set_animation, ":agent", "anim_shield_bash"),
(agent_get_troop_id, ":troop", ":agent"),
(troop_get_type, ":type", ":troop"),
(try_begin),
(eq, ":type", tf_male),
(agent_play_sound, ":agent", "snd_man_yell"),
(else_try),
(eq, ":type", tf_female),
(agent_play_sound, ":agent", "snd_woman_yell"),
(try_end),
(agent_play_sound, ":victim", "snd_wooden_hit_low_armor_high_damage"),
(agent_get_defend_action, ":action", ":victim"),
(try_begin),
(eq, ":action", 2), #Blocking.
(neg|position_is_behind_position, pos1, pos2), #If basher isn't behind victim.
(agent_get_wielded_item, ":item", ":victim", 1), #Offhand.
(gt, ":item", 0),
(item_get_type, ":type", ":item"),
(eq, ":type", itp_type_shield),
(agent_set_animation, ":victim", "anim_shield_bash"),
(else_try),
(agent_set_animation, ":victim", "anim_shield_strike"),
(try_end),
(try_end),
(agent_get_slot, ":timer", ":agent", sp_agent_shield_bash_timer),
(val_sub, ":timer", 1),
(val_max, ":timer", 0),
(agent_set_slot, ":agent", sp_agent_shield_bash_timer, ":timer"),
(try_end),
])
Kolejny krok to otworzenie module_animations.py. Szukamy:
["unused_human_anim_44", 0, 0, [1.0, "anim_human", 0, 1, 0]],
["unused_human_anim_45", 0, 0, [1.0, "anim_human", 0, 1, 0]],
U was te numerki mogą być inne. W każdym razie przed dwoma stawiamy # według wzoru:
#["unused_human_anim_44", 0, 0, [1.0, "anim_human", 0, 1, 0]],
#["unused_human_anim_45", 0, 0, [1.0, "anim_human", 0, 1, 0]],
Pod nimi (tymi dwoma) wklejamy te kody animacji:
["shield_bash", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
[0.50, "defend_shield_parry_all", 1, 50, blend_in_defense], #Adjust duration for balance. Currently at 0.50 seconds, fixed.
[0.50, "defend_shield_right", 1, 50, blend_in_defense],
[0.50, "defend_shield_left", 1, 50, blend_in_defense],
[0.50, "defend_shield_right", 1, 50, blend_in_defense],
],
["shield_strike", acf_enforce_all|acf_align_with_ground, amf_priority_striked|amf_play|amf_accurate_body|amf_restart,
[1.0, "anim_human", blow+5000, blow+5010, arf_blend_in_3|arf_make_custom_sound],
[1.7, "anim_human", blow+5400, blow+5453, arf_blend_in_2|arf_make_custom_sound],
[1.44, "anim_human", blow+5400, blow+5445, arf_blend_in_2|arf_make_custom_sound],
],
Skrypt mamy, animację mamy. Teraz czas na timer, by uderzenie tarczą nie było zbyt potężne. Domyślny czas przed użyciem uderzenia kolejny raz to 5 sekund (sekundy podajemy w tickach, czyli liczba 50 to 5 sekund).
Otwieramy module_constants.py i szukamy "agent slots". Pod innymi kodami w agent slots wklejamy ten:
sp_agent_shield_bash_timer = 50
Teraz przechodzimy do module_scripts.py. Szukamy "script_game_start:" i dodajemy ten kod:
(assign, "$sp_shield_bash", 1),
(assign, "$sp_shield_bash_ai", 1)
Wzór:
#script_game_start:
# This script is called when a new game is started
# INPUT: none
("game_start",
[
(faction_set_slot, "fac_player_supporters_faction", slot_faction_state, sfs_inactive),
(assign, "$g_player_luck", 200),
(assign, "$g_player_luck", 200),
(troop_set_slot, "trp_player", slot_troop_occupation, slto_kingdom_hero),
(store_random_in_range, ":starting_training_ground", training_grounds_begin, training_grounds_end),
(party_relocate_near_party, "p_main_party", ":starting_training_ground", 3),
(str_store_troop_name, s5, "trp_player"),
(party_set_name, "p_main_party", s5),
(call_script, "script_update_party_creation_random_lim its"),
(assign, "$g_player_party_icon", -1),
#Warband changes begin -- set this early
(try_for_range, ":npc", 0, kingdom_ladies_end),
(this_or_next|eq, ":npc", "trp_player"),
(is_between, ":npc", active_npcs_begin, kingdom_ladies_end),
(troop_set_slot, ":npc", slot_troop_father, -1),
(troop_set_slot, ":npc", slot_troop_mother, -1),
(troop_set_slot, ":npc", slot_troop_guardian, -1),
(troop_set_slot, ":npc", slot_troop_spouse, -1),
(troop_set_slot, ":npc", slot_troop_betrothed, -1),
(troop_set_slot, ":npc", slot_troop_prisoner_of_party, -1),
(troop_set_slot, ":npc", slot_lady_last_suitor, -1),
(troop_set_slot, ":npc", slot_troop_stance_on_faction_issue, -1),
(store_random_in_range, ":decision_seed", 0, 10000),
(troop_set_slot, ":npc", slot_troop_set_decision_seed, ":decision_seed"), #currently not used
(troop_set_slot, ":npc", slot_troop_temp_decision_seed, ":decision_seed"), #currently not used, holds for at least 24 hours
(try_end),
(assign, "$sp_shield_bash", 1),
(assign, "$sp_shield_bash_ai", 1),
(assign, "$g_lord_long_term_count", 0),
(call_script, "script_initialize_banner_info"),
(call_script, "script_initialize_item_info"),
(call_script, "script_initialize_aristocracy"),
(call_script, "script_initialize_npcs"),
(assign, "$disable_npc_complaints", 0),
#NPC companion changes end
# Setting random feast time
(try_for_range, ":faction_no", kingdoms_begin, kingdoms_end),
(store_random_in_range, ":last_feast_time", 0, 312), #240 + 72
(val_mul, ":last_feast_time", -1),
(faction_set_slot, ":faction_no", slot_faction_last_feast_start_time, ":last_feast_time"),
(try_end),
# Setting the random town sequence:
(store_sub, ":num_towns", towns_end, towns_begin),
(assign, ":num_iterations", ":num_towns"),
(try_for_range, ":cur_town_no", 0, ":num_towns"),
(troop_set_slot, "trp_random_town_sequence", ":cur_town_no", -1),
(try_end),
(assign, ":cur_town_no", 0),
(try_for_range, ":unused", 0, ":num_iterations"),
(store_random_in_range, ":random_no", 0, ":num_towns"),
(assign, ":is_unique", 1),
(try_for_range, ":cur_town_no_2", 0, ":num_towns"),
(troop_slot_eq, "trp_random_town_sequence", ":cur_town_no_2", ":random_no"),
(assign, ":is_unique", 0),
(try_end),
(try_begin),
(eq, ":is_unique", 1),
(troop_set_slot, "trp_random_town_sequence", ":cur_town_no", ":random_no"),
(val_add, ":cur_town_no", 1),
(else_try),
(val_add, ":num_iterations", 1),
(try_end),
(try_end),
Teraz wystarczy wrzucić to do wybranej misji w module_mission_templates.py:
sp_shield_bash_1,
sp_shield_bash_2,
sp_shield_bash_3,
Wzór:
(
"lead_charge",mtf_battle_mode|mtf_synch_inventory,charge,
"You lead your men to battle.",
[
(1,mtef_defenders|mtef_team_0,0,aif_start_alarmed,12,[]),
(0,mtef_defenders|mtef_team_0,0,aif_start_alarmed,0,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,12,[]),
(4,mtef_attackers|mtef_team_1,0,aif_start_alarmed,0,[]),
],
[
sp_shield_bash_1,
sp_shield_bash_2,
sp_shield_bash_3,
(ti_on_agent_spawn, 0, 0, [],
[
(store_trigger_param_1, ":agent_no"),
(call_script, "script_agent_reassign_team", ":agent_no"),
(assign, ":initial_courage_score", 5000),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(store_character_level, ":troop_level", ":troop_id"),
(val_mul, ":troop_level", 35),
(val_add, ":initial_courage_score", ":troop_level"), #average : 20 * 35 = 700
(store_random_in_range, ":randomized_addition_courage", 0, 3000), #average : 1500
(val_add, ":initial_courage_score", ":randomized_addition_courage"),
(agent_get_party_id, ":agent_party", ":agent_no"),
(party_get_morale, ":cur_morale", ":agent_party"),
(store_sub, ":morale_effect_on_courage", ":cur_morale", 70),
(val_mul, ":morale_effect_on_courage", 30), #this can effect morale with -2100..900
(val_add, ":initial_courage_score", ":morale_effect_on_courage"),
#average = 5000 + 700 + 1500 = 7200; min : 5700, max : 8700
#morale effect = min : -2100(party morale is 0), average : 0(party morale is 70), max : 900(party morale is 100)
#min starting : 3600, max starting : 9600, average starting : 7200
(agent_set_slot, ":agent_no", slot_agent_courage_score, ":initial_courage_score"),
]),
To już wszystko. Mam nadzieję, że pomogłem wielu osobom, gdyż wiem, że wszyscy tego szukali (a przynajmniej ci, którzy nie znają dobrze angielskiego).