I always think that tiny throwing weapons like daggers and knives should can be used as secondary secret weapons. A skillfull fighter should be able to pick the daggers from his belt and throw them lefthanded as surprising attack to his enemies.
So, here we bring the story to Warband.
Notes :
- It can run without WSE, but surely WSE will make it better (imod related things)
- I use Papa Lazarau's shield bash animation. I'll be happy if there's anyone can provide me more representative animation.
EDIT1 : To disable while crouching
EDIT2 : BUG FIX on script_cf_has_throwing_daggers, now it check the current ammo left.
EDIT3 : Add mission trigger for AI
EDIT4 : Balancing things and add randomization
So, here we bring the story to Warband.
Code:
slot_item_throwing_dagger = 105 # or any free slots
# for mods with no WSE SDK uncomments these lines :
# is_vanilla_warband = 1004 #(is_vanilla_warband), #Fails only when WSE is running
# agent_get_item_slot_modifier = 3301 #(agent_get_item_slot_modifier, <destination>, <agent_no>, <item_slot_no>), #Stores <agent_no>'s <item_slot_no> modifier into <destination>
# agent_get_item_slot_ammo = 3305 #(agent_get_item_slot_ammo, <destination>, <agent_no>, <item_slot_no>), #Stores <agent_no>'s <item_slot_no> ammo count into <destination>
# agent_set_item_slot_ammo = 3306 #(agent_set_item_slot_ammo, <agent_no>, <item_slot_no>, <value>), #Sets <agent_no>'s <item_slot_no> ammo count to <value>
Code:
# Rubik's "at compiling time" slots assignment
def set_flying_daggers():
flying_dagger = []
for i_item in xrange(len(items)):
if type==itp_type_thrown:
if (items[i_item][4] & itcf_throw_knife)==itcf_throw_knife:
flying_dagger.append((item_set_slot, i_item, slot_item_throwing_dagger, get_missile_speed(items[i_item][6])))
return flying_dagger[:]
Code:
("init_flying_daggers", set_flying_daggers()),
Code:
("cf_has_throwing_daggers",
[(store_script_param_1, ":agent_no"),
(assign, ":slot", -1),
(try_for_range, ":slot_no", 0, 4),
(eq, ":slot", -1),
(agent_get_item_slot, ":weapon_no", ":agent_no", ":slot_no"),
(ge, ":weapon_no", 0),
(neg|item_slot_eq, ":weapon_no", slot_item_throwing_dagger, 0),
(agent_get_ammo_for_slot, ":cur_ammo", ":agent_no", ":slot_no"),
(gt, ":cur_ammo", 0),
(assign, ":slot", ":slot_no"),
(try_end),
(ge, ":slot", 0),
(assign, reg0, ":weapon_no"), (assign, reg1, ":slot"), ]),
("quick_throw",
[(store_script_param, ":agent_no", 1),
(store_script_param, ":weapon_no", 2),
(store_script_param, ":slot", 3),
(try_begin),
(assign, ":mod", 0),
(is_vanilla_warband),
(try_begin),
(agent_get_ammo_for_slot, ":cur_ammo", ":agent_no", ":slot"),
(gt, ":cur_ammo", 0),(val_sub, ":cur_ammo", 1),
(agent_set_ammo,":agent_no",":weapon_no",":cur_ammo"),
(else_try),
(assign, ":mod", -1),
(try_end),
(else_try),
(agent_get_item_slot_modifier, ":mod", ":agent_no", ":slot"),
(try_begin),
(agent_get_item_slot_ammo, ":cur_ammo", ":agent_no", ":slot"),
(gt, ":cur_ammo", 0),(val_sub, ":cur_ammo", 1),
(agent_set_item_slot_ammo, ":agent_no",":slot",":cur_ammo"),
(else_try),
(assign, ":mod", -1),
(try_end),
(try_end),
(try_begin),
(ge, ":mod", 0),
(agent_set_animation, ":agent_no", "anim_shield_bash"), # the animation, Papa Lazarau's shield bash anim
(set_fixed_point_multiplier, 100),
(agent_get_position, pos61, ":agent_no"),
(position_move_y,pos61,35),#35 cm directly ahead, so it's not a cuboid space around player center
(position_move_z,pos61,100),
(agent_get_troop_id, ":troop_id", ":agent_no"),
(store_proficiency_level,":prof", ":troop_id", wpt_throwing),
(store_random_in_range, ":prof_factor", 0, ":prof"),
(item_get_slot,":speed", ":weapon_no", slot_item_throwing_dagger),
(val_add, ":speed", ":prof_factor"), (val_mul, ":speed", 100),
(store_random_in_range, ":prof_factor", 0, ":prof"),
(try_begin),
(store_sub, ":prof", 100, ":prof_factor"), (val_mul, ":prof", 15), (val_div, ":prof", 100),
(store_mul, ":prof1", ":prof", -1),
(store_random_in_range, ":prof_factor", ":prof1", ":prof"),
(position_rotate_z, pos61, ":prof_factor"),
(try_end),
(add_missile, ":agent_no", pos61, ":speed", ":weapon_no", ":mod", ":weapon_no", ":mod"),
(try_end), ]),
Code:
player_do_special_moves = (0, 0, 1,
[(neg|main_hero_fallen),(game_key_is_down, gk_defend),(key_clicked, key_left_mouse_button),
(get_player_agent_no, ":player_agent"),
(agent_get_horse, ":check", ":player_agent"), # not mounting
(le, ":check", 0),
(agent_get_crouch_mode, ":check",":player_agent"), # not crouching
(eq, ":check", 0),
(agent_get_wielded_item, ":shield", ":player_agent", 1),
(le, ":shield", 0),
(agent_get_wielded_item, ":weapon", ":player_agent", 0),
(gt, ":weapon", 0),
(item_get_type, ":weapon_type", ":weapon"),
(try_begin),
(eq, ":weapon_type", itp_type_one_handed_wpn),
(call_script, "script_cf_has_throwing_daggers", ":player_agent"),
(assign, ":weapon", reg0), (assign, ":slot", reg1),
(call_script, "script_quick_throw", ":player_agent", ":weapon", ":slot"),
(try_end),] ,[])
ai_do_special_moves = (0.1, 0, 0,
[(try_for_agents, ":agent"),
(agent_is_active, ":agent"), (agent_is_alive,":agent"), (agent_is_human, ":agent"),
(agent_get_horse, ":check", ":agent"), # not mounting
(le, ":check", 0),
(agent_get_crouch_mode, ":check",":agent"), # not crouching
(eq, ":check", 0),
(agent_get_wielded_item, ":shield", ":agent", 1),
(le, ":shield", 0),
(agent_get_wielded_item, ":weapon", ":agent", 0),
(gt, ":weapon", 0),
(item_get_type, ":weapon_type", ":weapon"),
(eq, ":weapon_type", itp_type_one_handed_wpn),
(call_script, "script_cf_has_throwing_daggers", ":agent"),
(assign, ":weapon", reg0), (assign, ":slot", reg1),
(agent_get_troop_id, ":troop_no", ":agent"),
(store_proficiency_level, ":prof", ":troop_no", wpt_throwing),
(val_div, ":prof", 30),
(store_random_in_range, ":check", -3, 10),
(val_sub, ":prof", ":check"),
(agent_get_defend_action, ":check", ":agent"),
(val_add, ":prof", ":check"),
(gt, ":prof", 1),
(agent_ai_get_behavior_target, ":victim_agent", ":agent"),
(agent_is_active, ":victim_agent"),
(agent_is_alive,":victim_agent"),
(agent_is_human, ":victim_agent"),
(agent_get_team, ":team1", ":agent"),
(agent_get_team, ":team2", ":victim_agent"),
(neq, ":team1", ":team2"),
(teams_are_enemies,":team1", ":team2"),
(agent_get_position, pos61, ":agent"),
(agent_get_position,pos62,":victim_agent"),
(position_transform_position_to_local, pos63, pos62, pos61),
(position_get_x, ":check", pos63),
(is_between,":check", -10, 11),
(position_get_y, ":check", pos63),
(is_between,":check", 50, 600),
(call_script, "script_quick_throw", ":agent", ":weapon", ":slot"),
(try_end),] ,[])
Code:
player_do_special_moves, ai_do_special_moves,
- It can run without WSE, but surely WSE will make it better (imod related things)
- I use Papa Lazarau's shield bash animation. I'll be happy if there's anyone can provide me more representative animation.
EDIT1 : To disable while crouching
EDIT2 : BUG FIX on script_cf_has_throwing_daggers, now it check the current ammo left.
EDIT3 : Add mission trigger for AI
EDIT4 : Balancing things and add randomization