OSP Code Combat [WRECK] in-battle command calling

Users who are viewing this thread

Ikaguia

Grandmaster Knight
This is a modmerger plugin that makes a presentation that allows you to type and recognize commands inside missions using a slowed down time so as to not make you stand ildly in the midst of a battle. this can be used by mods that wish to add some sort of casting system for magic or even foreign speech.

THIS CODE DEPENDS HEAVILY ON WRECK TO WORK

without further delay here is the code:

Code:
from compiler import *
register_plugin()

## in-batle command callig

ibcc_max_slow_duration = 8#second
ibcc_max_slow          = 100#/1000 of normal speed
ibcc_slow_fade_time    = 4#seconds it takes to go back to normal speed after ibcc_max_slow_duration

presentations = [
	("ibcc_type",prsntf_read_only,0,[
		(ti_on_presentation_load,[
			(set_fixed_point_multiplier,1000),
			(presentation_set_duration, 100000000),
			(assign,g.ibcc_text_x,50),
			(assign,g.ibcc_text,-1),
			(assign,g.ibcc_prsnt_state,1),
			(ui_create_textbox, g.ibcc_bg2, 1000, 1000, 1, 1),
			(ui_create_mesh, g.ibcc_bg1, mesh.inv_slot, 0, 0, 12*1000, 12*750),
			(overlay_set_color, g.ibcc_bg1, 0x000000),
			(overlay_set_alpha, g.ibcc_bg1, 0x00),
			(overlay_animate_to_alpha, g.ibcc_bg1, ibcc_max_slow_duration * ibcc_max_slow, 0xbf),#fade in while its on max slow
			(mission_set_time_speed,ibcc_max_slow),
			]),
		(ti_on_presentation_run,[
			(set_fixed_point_multiplier,1000),
			(store_trigger_param_1,l.time),
			(overlay_obtain_focus, g.ibcc_bg2),#to prevent warband hardcoded screens from interupting the typing
			(try_begin),
				(this_or_next|eq,g.ibcc_prsnt_state,-1),
				(eq,g.ibcc_prsnt_state,2),
				(this_or_next|eq,g.ibcc_prsnt_state,-1),
				#(ge,l.time,(ibcc_max_slow_duration + ibcc_slow_fade_time) * ibcc_max_slow),
				(ge,l.time,(ibcc_max_slow_duration + ibcc_slow_fade_time) * 1000),
				(assign,g.ibcc_prsnt_state,-1),
				#(display_message,"@ending prsnt"),
				(mission_time_speed_move_to_value,1000,1000),
				(presentation_set_duration,0),
			(else_try),
				(eq,g.ibcc_prsnt_state,1),
				#(ge,l.time,ibcc_max_slow_duration * ibcc_max_slow),
				(ge,l.time,ibcc_max_slow_duration * 1000),
				(assign,g.ibcc_prsnt_state,2),
				#(display_message,"@decreasing slow"),
				(overlay_animate_to_alpha, g.ibcc_bg1, ibcc_slow_fade_time * ibcc_max_slow, 0x00),#fade out with the slow
				(mission_time_speed_move_to_value,1000,ibcc_slow_fade_time * ibcc_max_slow),
			(try_end),
			(get_key_clicked, l.key),
			(try_begin),
				(eq,l.key,-1),
			(else_try),
				(eq,l.key,g.ibcc_hotkey),
				(eq,g.ibcc_text,-1),
				(assign,g.ibcc_text,0),
			(else_try),
				(eq,l.key,key_enter),
				#(display_message,"@Clicked enter"),
				(call_script,script.current_word_apply),## you can use this to apply negative or lessened effects when you misscast something
				(assign,g.ibcc_prsnt_state,-1),
				(mission_time_speed_move_to_value,1000,1000),
				(overlay_animate_to_alpha, g.ibcc_bg1, 1000, 0x00),#fade out with the slow
				(try_for_range,l.overlay,g.ibcc_bg1+1,g.ibcc_bg1+1+g.ibcc_text),
					(position_set_x,pos1,1100),
					(position_set_y,pos1,1100),
					(overlay_animate_to_size, l.overlay, 250, pos1),
				(try_end),
			(else_try),
				(call_script,script.get_key_name,l.key),
				(eq,l.key,key_space),
				(str_store_string,s1,"@ "),
				(eq,1,0),
			(else_try),
				(this_or_next_is_key_letter,l.key),
				(this_or_next_is_key_number,l.key),
				(eq,l.key,key_space),
				(store_random_in_range,l.x,0,1000),
				(store_random_in_range,l.y,0,750),
				(ui_create_label,l.overlay,s1,l.x,l.y,0,4000),
				(overlay_set_alpha, l.overlay, 0x00),
				(overlay_animate_to_alpha, l.overlay, 1000, 0xbf),#fade in
				(position_set_x,pos1,1000),
				(position_set_y,pos1,1000),
				(overlay_animate_to_size, l.overlay, 750, pos1),
				(position_set_x,pos1,g.ibcc_text_x),
				(position_set_y,pos1,500),
				(overlay_animate_to_position, l.overlay, 750, pos1),
				(val_add,g.ibcc_text_x,20),
				(troop_set_slot,trp.ibcc_temp,g.ibcc_text,l.key),##save the word to ibcc_temp
				(troop_set_slot,trp.ibcc_temp,g.ibcc_text+1,-1),##just to be sure
				(val_add,g.ibcc_text,1),
				#(call_script,script.get_key_name,l.key),
				#(display_message,"@Clicked {s1}"),
			(try_end),
			###comment this part out if you dont want to break the prsntation as soon as the word is invalid
			(try_begin),
				(call_script,script.cf_current_word_is_valid),##check if using the current word you can write a valid one
			(else_try),
				(call_script,script.current_word_apply),## you can use this to apply negative or lessened effects when you misscast something
				##TODO: make some sort of breaking mesh animation and display a message
				(assign,g.ibcc_prsnt_state,3),
				(mission_time_speed_move_to_value,1000,1),
			(try_end),
			###comment this part out if you want your leters to stay static at the screen
			(try_for_range,l.overlay,g.ibcc_bg1+1,g.ibcc_bg1+1+g.ibcc_text),
				(eq,g.ibcc_prsnt_state,1),
				## make them change size at irregular intervals
				(store_mod,l.temp1,l.overlay,10),
				(store_mod,l.temp2,l.time,10),
				(eq,l.temp1,l.temp2),
				##
				(store_random_in_range,l.x,800,1200),
				(store_random_in_range,l.y,800,1200),
				(position_set_x,pos1,l.x),
				(position_set_y,pos1,l.y),
				(overlay_animate_to_size, l.overlay, 1000, pos1),
			(try_end),
			]),
		]),
]

troops = [
	["ibcc_temp","temp","temp",tf_hero,0,0,0,[],0,0,0,0],
]

words = [
	##examples: potato mg/potato throw
	(key_p,key_o,key_t,key_a,key_t,key_o,key_space,key_m,key_g),
	(key_p,key_o,key_t,key_a,key_t,key_o,key_space,key_t,key_h,key_r,key_o,key_w),
]

script_block = [
	(assign,l.result,0),
]

def word_block_insert(block,i,j):
	block += [
			(lt,g.ibcc_text,j+1),
			(assign,l.result,1),
	]
	if j<len(words[i]):
		block += [
			(else_try),
				(troop_slot_eq,trp.ibcc_temp,j,words[i][j]),
				(try_begin),
		]
		word_block_insert(block,i,j+1),
		block += [
				(try_end),
		]

for i in xrange(len(words)):
	script_block += [(try_begin),]
	word_block_insert(script_block,i,0),
	script_block += [(try_end),]
script_block += [
	(try_begin),
		(eq,l.result,0),
		(str_store_string,s0,"@check failed on "),
		(assign,l.temp,1),
		(try_for_range,l.slot,0,l.temp),
			(neg|troop_slot_eq,trp.ibcc_temp,l.slot+1,-1),
			(val_add,l.temp,1),
			(troop_get_slot,l.key,trp.ibcc_temp,l.slot),
			(call_script,script.get_key_name,l.key),
			(str_store_string,s0,"@{s0}{s1}"),
			(neg|troop_slot_eq,trp.ibcc_temp,l.slot+2,-1),
			(str_store_string,s0,"@{s0}, "),
		(try_end),
		(display_message,s0),
	(try_end),
	(eq,l.result,1),
]

scripts = [
	("cf_current_word_is_valid",script_block),
	("current_word_apply",[
		(try_begin),
			(troop_slot_eq,trp.ibcc_temp, 0,key_p),
			(troop_slot_eq,trp.ibcc_temp, 1,key_o),
			(troop_slot_eq,trp.ibcc_temp, 2,key_t),
			(troop_slot_eq,trp.ibcc_temp, 3,key_a),
			(troop_slot_eq,trp.ibcc_temp, 4,key_t),
			(troop_slot_eq,trp.ibcc_temp, 5,key_o),
			(troop_slot_eq,trp.ibcc_temp, 6,key_space),
			(troop_slot_eq,trp.ibcc_temp, 7,key_t),
			(troop_slot_eq,trp.ibcc_temp, 8,key_h),
			(troop_slot_eq,trp.ibcc_temp, 9,key_r),
			(troop_slot_eq,trp.ibcc_temp,10,key_o),
			(troop_slot_eq,trp.ibcc_temp,11,key_w),
			(troop_slot_eq,trp.ibcc_temp,12,-1),
			(assign,g.throw_potatoes,1),
		(try_end),
		(try_begin),
			(troop_slot_eq,trp.ibcc_temp, 0,key_p),
			(troop_slot_eq,trp.ibcc_temp, 1,key_o),
			(troop_slot_eq,trp.ibcc_temp, 2,key_t),
			(troop_slot_eq,trp.ibcc_temp, 3,key_a),
			(troop_slot_eq,trp.ibcc_temp, 4,key_t),
			(troop_slot_eq,trp.ibcc_temp, 5,key_o),
			(troop_slot_eq,trp.ibcc_temp, 6,key_space),
			(troop_slot_eq,trp.ibcc_temp, 7,key_m),
			(troop_slot_eq,trp.ibcc_temp, 8,key_g),
			(troop_slot_eq,trp.ibcc_temp, 9,-1),
			(assign,g.throw_potatoes,100),
		(try_end),
		]),
]

items = [
	##this items are not necessary for the kit, they are just here for the two examples
	["potato_bow","Potato Bow", [("hunting_bow",0), ("hunting_bow_carry",ixmesh_carry)], itp_type_bow |itp_primary|itp_two_handed,itcf_shoot_bow|itcf_carry_bow_back, 0, weight(1.5)|spd_rtng(90) | shoot_speed(40) | thrust_damage(1, blunt),0],
	#["potato_arrow","Potatoes", [("throwing_stone",0),("throwing_stone",ixmesh_flying_ammo)], itp_type_arrows, itcf_carry_quiver_back, 0,weight(1.5)|weapon_length(95)|max_ammo(80),0],
	["potato_arrow","Potatoes", [("potato",0),("potato",ixmesh_flying_ammo),("potato_bag", ixmesh_carry)], itp_type_arrows, itcf_carry_quiver_back, 0,weight(1.5)|weapon_length(5)|max_ammo(80),0],
]

injection = {
	'ibcc_triggers' : [##mission templates
		##this trigger is not necesarry for the kit, it is just here for the two examples
		(0.1,0,3,[
			(neg|main_hero_fallen),
			(ge,g.throw_potatoes,1),
			#(display_message,"@Firing potato!!"),
			(val_sub,g.throw_potatoes,1),
			(get_player_agent_no,l.agent),
			(set_fixed_point_multiplier,1000),
			####(agent_get_bone_position, pos1, l.agent, 9),#get head level, in case player is on horse or jumping ## not working properly when jumping on a horse
			####(position_get_distance_to_ground_level,l.dist,pos1),
			(agent_get_position, pos1, l.agent),
			##(agent_get_look_position, pos2, l.agent),
			####(position_move_z, pos1, l.dist, 1),
			(try_begin),
				(agent_get_horse,l.horse,l.agent),
				(agent_is_active,l.horse),
				(agent_is_alive,l.horse),
				(position_move_z, pos1, 50, 1),
			(try_end),
			(position_move_z, pos1, 200, 1),
			##(position_aim_at_position, pos1, pos2),
			(position_move_y, pos1, 5, 0),
			(add_missile,l.agent,pos1,25000,itm.potato_bow,0,itm.potato_arrow,0),
			#(set_spawn_position, pos1),
			#(spawn_item, itm.potato_bow),
			(lt,g.throw_potatoes,1),
		],[]),
		(0,0,5,[
			(neg|main_hero_fallen),
			(key_clicked,g.ibcc_hotkey),
			(neg|is_presentation_active,prsnt.ibcc_type),
			(eq,g.ibcc_prsnt_state,-1),
			(assign,g.ibcc_prsnt_state,0),
			(start_presentation,prsnt.ibcc_type),
		],[]),
		(1,0,10,[##this is here due to (presentation_set_duration) working on all active and messing up with mission speed
			(is_presentation_active,prsnt.ibcc_type),
			(eq,g.ibcc_prsnt_state,-1),
			(presentation_set_duration,0),
			(set_fixed_point_multiplier,1000),
			(mission_time_speed_move_to_value,1000,1000),
		],[]),
		(1,0,10,[##this is here due to (presentation_set_duration) working on all active and messing up with mission speed
			(neg|is_presentation_active,prsnt.ibcc_type),
			(neq,g.ibcc_prsnt_state,-1),
			(assign,g.ibcc_prsnt_state,-1),
			(set_fixed_point_multiplier,1000),
			(mission_time_speed_move_to_value,1000,1000),
		],[]),
	],
	'inject_game_start' : [
		(assign,g.ibcc_prsnt_state,-1),
		(assign,g.ibcc_hotkey,key_z),
	],
}
Code:
KEYBOARD_KEYS = (
  key_escape, key_f1, key_f2, key_f3, key_f4, key_f5, key_f6, key_f7, key_f8, key_f9, key_f10, key_f11, key_f12, 
  key_1, key_2, key_3, key_4, key_5, key_6, key_7, key_8, key_9, key_0, 
  key_a, key_b, key_c, key_d, key_e, key_f, key_g, key_h, key_i, key_j, key_k, key_l, key_m, key_n, key_o, key_p, key_q, key_r, key_s, key_t, key_u, key_v, key_w, key_x, key_y, key_z,
  key_open_braces, key_close_braces, key_comma, key_period, key_slash, key_back_slash, key_equals, key_minus, key_semicolon, key_apostrophe, key_tilde, 
  key_space, key_enter, key_tab, key_back_space, key_caps_lock, key_left_shift, key_right_shift, key_left_control, key_right_control, key_left_alt, key_right_alt, 
  key_insert, key_delete, key_home, key_end, key_page_up, key_page_down, key_up, key_down, key_left, key_right, 
  key_numpad_0, key_numpad_1, key_numpad_2, key_numpad_3, key_numpad_4, key_numpad_5, key_numpad_6, key_numpad_7, key_numpad_8, key_numpad_9, key_num_lock, key_numpad_slash, key_numpad_multiply, key_numpad_minus, key_numpad_plus, key_numpad_enter, key_numpad_period, 
  key_mouse_scroll_up, key_mouse_scroll_down, key_left_mouse_button, key_right_mouse_button, key_middle_mouse_button, key_mouse_button_4, key_mouse_button_5, key_mouse_button_6, key_mouse_button_7, key_mouse_button_8, 
  key_xbox_a, key_xbox_b, key_xbox_x, key_xbox_y, key_xbox_dpad_up, key_xbox_dpad_down, key_xbox_dpad_right, key_xbox_dpad_left, key_xbox_start, key_xbox_back, key_xbox_rbumper, key_xbox_lbumper, key_xbox_ltrigger, key_xbox_rtrigger, key_xbox_rstick, key_xbox_lstick
)

KEYBOARD_KEYS_LETTER = (
  key_a, key_b, key_c, key_d, key_e, key_f, key_g, key_h, key_i, key_j, key_k, key_l, key_m, key_n, key_o, key_p, key_q, key_r, key_s, key_t, key_u, key_v, key_w, key_x, key_y, key_z,
)

KEYBOARD_KEYS_NUM = (
  key_1, key_2, key_3, key_4, key_5, key_6, key_7, key_8, key_9, key_0,
  key_numpad_0, key_numpad_1, key_numpad_2, key_numpad_3, key_numpad_4, key_numpad_5, key_numpad_6, key_numpad_7, key_numpad_8, key_numpad_9,
)

scripts = [

	#script_get_key_name
	("get_key_name",[
		(store_script_param_1,":key"),
		(try_begin),
			(eq,":key",-1),
			(str_store_string,s1,"@Disabled"),
		(else_try),
			(eq,":key",key_1),
			(str_store_string,s1,"@1"),
		(else_try),
			(eq,":key",key_2),
			(str_store_string,s1,"@2"),
		(else_try),
			(eq,":key",key_3),
			(str_store_string,s1,"@3"),
		(else_try),
			(eq,":key",key_4),
			(str_store_string,s1,"@4"),
		(else_try),
			(eq,":key",key_5),
			(str_store_string,s1,"@5"),
		(else_try),
			(eq,":key",key_6),
			(str_store_string,s1,"@6"),
		(else_try),
			(eq,":key",key_7),
			(str_store_string,s1,"@7"),
		(else_try),
			(eq,":key",key_8),
			(str_store_string,s1,"@8"),
		(else_try),
			(eq,":key",key_9),
			(str_store_string,s1,"@9"),
		(else_try),
			(eq,":key",key_0),
			(str_store_string,s1,"@0"),
		(else_try),
			(eq,":key",key_a),
			(str_store_string,s1,"@A"),
		(else_try),
			(eq,":key",key_b),
			(str_store_string,s1,"@B"),
		(else_try),
			(eq,":key",key_c),
			(str_store_string,s1,"@C"),
		(else_try),
			(eq,":key",key_d),
			(str_store_string,s1,"@D"),
		(else_try),
			(eq,":key",key_e),
			(str_store_string,s1,"@E"),
		(else_try),
			(eq,":key",key_f),
			(str_store_string,s1,"@F"),
		(else_try),
			(eq,":key",key_g),
			(str_store_string,s1,"@G"),
		(else_try),
			(eq,":key",key_h),
			(str_store_string,s1,"@H"),
		(else_try),
			(eq,":key",key_i),
			(str_store_string,s1,"@I"),
		(else_try),
			(eq,":key",key_j),
			(str_store_string,s1,"@J"),
		(else_try),
			(eq,":key",key_k),
			(str_store_string,s1,"@K"),
		(else_try),
			(eq,":key",key_l),
			(str_store_string,s1,"@L"),
		(else_try),
			(eq,":key",key_m),
			(str_store_string,s1,"@M"),
		(else_try),
			(eq,":key",key_n),
			(str_store_string,s1,"@N"),
		(else_try),
			(eq,":key",key_o),
			(str_store_string,s1,"@O"),
		(else_try),
			(eq,":key",key_p),
			(str_store_string,s1,"@P"),
		(else_try),
			(eq,":key",key_q),
			(str_store_string,s1,"@Q"),
		(else_try),
			(eq,":key",key_r),
			(str_store_string,s1,"@R"),
		(else_try),
			(eq,":key",key_s),
			(str_store_string,s1,"@S"),
		(else_try),
			(eq,":key",key_t),
			(str_store_string,s1,"@T"),
		(else_try),
			(eq,":key",key_u),
			(str_store_string,s1,"@U"),
		(else_try),
			(eq,":key",key_v),
			(str_store_string,s1,"@V"),
		(else_try),
			(eq,":key",key_w),
			(str_store_string,s1,"@W"),
		(else_try),
			(eq,":key",key_x),
			(str_store_string,s1,"@X"),
		(else_try),
			(eq,":key",key_y),
			(str_store_string,s1,"@Y"),
		(else_try),
			(eq,":key",key_z),
			(str_store_string,s1,"@Z"),
		(else_try),
			(eq,":key",key_numpad_0),
			(str_store_string,s1,"@Numpad 0"),
		(else_try),
			(eq,":key",key_numpad_1),
			(str_store_string,s1,"@Numpad 1"),
		(else_try),
			(eq,":key",key_numpad_2),
			(str_store_string,s1,"@Numpad 2"),
		(else_try),
			(eq,":key",key_numpad_3),
			(str_store_string,s1,"@Numpad 3"),
		(else_try),
			(eq,":key",key_numpad_4),
			(str_store_string,s1,"@Numpad 4"),
		(else_try),
			(eq,":key",key_numpad_5),
			(str_store_string,s1,"@Numpad 5"),
		(else_try),
			(eq,":key",key_numpad_6),
			(str_store_string,s1,"@Numpad 6"),
		(else_try),
			(eq,":key",key_numpad_7),
			(str_store_string,s1,"@Numpad 7"),
		(else_try),
			(eq,":key",key_numpad_8),
			(str_store_string,s1,"@Numpad 8"),
		(else_try),
			(eq,":key",key_numpad_9),
			(str_store_string,s1,"@Numpad 9"),
		(else_try),
			(eq,":key",key_num_lock),
			(str_store_string,s1,"@Num Lock"),
		(else_try),
			(eq,":key",key_numpad_slash),
			(str_store_string,s1,"@Numpad /"),
		(else_try),
			(eq,":key",key_numpad_multiply),
			(str_store_string,s1,"@Numpad *"),
		(else_try),
			(eq,":key",key_numpad_minus),
			(str_store_string,s1,"@Numpad -"),
		(else_try),
			(eq,":key",key_numpad_plus),
			(str_store_string,s1,"@Numpad +"),
		(else_try),
			(eq,":key",key_numpad_enter),
			(str_store_string,s1,"@Numpad Enter"),
		(else_try),
			(eq,":key",key_numpad_period),
			(str_store_string,s1,"@Numpad ."),
		(else_try),
			(eq,":key",key_insert),
			(str_store_string,s1,"@Insert"),
		(else_try),
			(eq,":key",key_delete),
			(str_store_string,s1,"@Delete"),
		(else_try),
			(eq,":key",key_home),
			(str_store_string,s1,"@Home"),
		(else_try),
			(eq,":key",key_end),
			(str_store_string,s1,"@End"),
		(else_try),
			(eq,":key",key_page_up),
			(str_store_string,s1,"@Pg Up"),
		(else_try),
			(eq,":key",key_page_down),
			(str_store_string,s1,"@Pg Down"),
		(else_try),
			(eq,":key",key_up),
			(str_store_string,s1,"@Up Arrow"),
		(else_try),
			(eq,":key",key_down),
			(str_store_string,s1,"@Down Arrow"),
		(else_try),
			(eq,":key",key_left),
			(str_store_string,s1,"@Left Arrow"),
		(else_try),
			(eq,":key",key_right),
			(str_store_string,s1,"@Right Arrow"),
		(else_try),
			(eq,":key",key_f1),
			(str_store_string,s1,"@F1"),
		(else_try),
			(eq,":key",key_f2),
			(str_store_string,s1,"@F2"),
		(else_try),
			(eq,":key",key_f3),
			(str_store_string,s1,"@F3"),
		(else_try),
			(eq,":key",key_f4),
			(str_store_string,s1,"@F4"),
		(else_try),
			(eq,":key",key_f5),
			(str_store_string,s1,"@F5"),
		(else_try),
			(eq,":key",key_f6),
			(str_store_string,s1,"@F6"),
		(else_try),
			(eq,":key",key_f7),
			(str_store_string,s1,"@F7"),
		(else_try),
			(eq,":key",key_f8),
			(str_store_string,s1,"@F8"),
		(else_try),
			(eq,":key",key_f9),
			(str_store_string,s1,"@F9"),
		(else_try),
			(eq,":key",key_f10),
			(str_store_string,s1,"@F10"),
		(else_try),
			(eq,":key",key_f11),
			(str_store_string,s1,"@F11"),
		(else_try),
			(eq,":key",key_f12),
			(str_store_string,s1,"@F12"),
		(else_try),
			(eq,":key",key_space),
			(str_store_string,s1,"@Spacebar"),
		(else_try),
			(eq,":key",key_escape),
			(str_store_string,s1,"@Esc"),
		(else_try),
			(eq,":key",key_enter),
			(str_store_string,s1,"@Enter"),
		(else_try),
			(eq,":key",key_tab),
			(str_store_string,s1,"@Tab"),
		(else_try),
			(eq,":key",key_back_space),
			(str_store_string,s1,"@Backspace"),
		(else_try),
			(eq,":key",key_open_braces),
			(str_store_string,s1,"@ [ "),
		(else_try),
			(eq,":key",key_close_braces),
			(str_store_string,s1,"@ ] "),
		(else_try),
			(eq,":key",key_comma),
			(str_store_string,s1,"@ , "),
		(else_try),
			(eq,":key",key_period),
			(str_store_string,s1,"@ . "),
		(else_try),
			(eq,":key",key_slash),
			(str_store_string,s1,"@ / "),
		(else_try),
			(eq,":key",key_back_slash),
			(str_store_string,s1,"@ \ "),
		(else_try),
			(eq,":key",key_equals),
			(str_store_string,s1,"@ = "),
		(else_try),
			(eq,":key",key_minus),
			(str_store_string,s1,"@ - "),
		(else_try),
			(eq,":key",key_semicolon),
			(str_store_string,s1,"@ ; "),
		(else_try),
			(eq,":key",key_apostrophe),
			(str_store_string,s1,"@ ' "),
		(else_try),
			(eq,":key",key_tilde),
			(str_store_string,s1,"@ ~ "),
		(else_try),
			(eq,":key",key_caps_lock),
			(str_store_string,s1,"@Caps Lock"),
		(else_try),
			(eq,":key",key_left_shift),
			(str_store_string,s1,"@Left Shift"),
		(else_try),
			(eq,":key",key_right_shift),
			(str_store_string,s1,"@Right Shift"),
		(else_try),
			(eq,":key",key_left_control),
			(str_store_string,s1,"@Left Cntrl"),
		(else_try),
			(eq,":key",key_right_control),
			(str_store_string,s1,"@Right Cntrl"),
		(else_try),
			(eq,":key",key_left_alt),
			(str_store_string,s1,"@Left Alt"),
		(else_try),
			(eq,":key",key_right_alt),
			(str_store_string,s1,"@Right Alt"),
		(else_try),
			(eq,":key",key_left_mouse_button),
			(str_store_string,s1,"@Left Mouse Button"),
		(else_try),
			(eq,":key",key_right_mouse_button),
			(str_store_string,s1,"@Right Mouse Button"),
		(else_try),
			(eq,":key",key_middle_mouse_button),
			(str_store_string,s1,"@Middle Mouse Button"),
		(else_try),
			(eq,":key",key_mouse_button_4),
			(str_store_string,s1,"@Mouse Button 4"),
		(else_try),
			(eq,":key",key_mouse_button_5),
			(str_store_string,s1,"@Mouse Button 5"),
		(else_try),
			(eq,":key",key_mouse_button_6),
			(str_store_string,s1,"@Mouse Button 6"),
		(else_try),
			(eq,":key",key_mouse_button_7),
			(str_store_string,s1,"@Mouse Button 7"),
		(else_try),
			(eq,":key",key_mouse_button_8),
			(str_store_string,s1,"@Mouse Button 8"),
		(else_try),
			(eq,":key",key_mouse_scroll_up),
			(str_store_string,s1,"@Mouse Scroll Up"),
		(else_try),
			(eq,":key",key_mouse_scroll_down),
			(str_store_string,s1,"@Mouse Scroll Down"),
		(else_try),
			(eq,":key",key_xbox_a),
			(str_store_string,s1,"@xBox A"),
		(else_try),
			(eq,":key",key_xbox_b),
			(str_store_string,s1,"@xBox b"),
		(else_try),
			(eq,":key",key_xbox_x),
			(str_store_string,s1,"@xBox x"),
		(else_try),
			(eq,":key",key_xbox_y),
			(str_store_string,s1,"@xBox y"),
		(else_try),
			(eq,":key",key_xbox_dpad_up),
			(str_store_string,s1,"@d Pad Up"),
		(else_try),
			(eq,":key",key_xbox_dpad_down),
			(str_store_string,s1,"@d Pad Down"),
		(else_try),
			(eq,":key",key_xbox_dpad_right),
			(str_store_string,s1,"@xBox dPad Right"),
		(else_try),
			(eq,":key",key_xbox_dpad_left),
			(str_store_string,s1,"@xBox dPad Left"),
		(else_try),
			(eq,":key",key_xbox_start),
			(str_store_string,s1,"@xBox Start"),
		(else_try),
			(eq,":key",key_xbox_back),
			(str_store_string,s1,"@xBox Back"),
		(else_try),
		#	(eq,":key",key_xbox_rbumber),
		#	(str_store_string,s1,"@xBox Right Bumber"),
		#(else_try),
		#	(eq,":key",key_xbox_lbumber),
		#	(str_store_string,s1,"@xBox Left Bumber "),
		#(else_try),
			(eq,":key",key_xbox_ltrigger),
			(str_store_string,s1,"@xBox Right Trigger"),
		(else_try),
			(eq,":key",key_xbox_rtrigger),
			(str_store_string,s1,"@xBox Left Trigger"),
		(else_try),
			(eq,":key",key_xbox_rstick),
			(str_store_string,s1,"@xBox Right Stick"),
		(else_try),
			(eq,":key",key_xbox_lstick),
			(str_store_string,s1,"@xBox Left Stick"),
		(try_end),
		]),
]


def get_key_clicked(destination,*argl):
	block = [
		(assign,destination,-1),
		(try_begin),
			(eq,1,0),
	]
	for i_key in range(len(KEYBOARD_KEYS)):
		key = KEYBOARD_KEYS[i_key]
		block.append((else_try))
		block.append((key_clicked,key))
		block.append((assign,destination,key))
	block.append((try_end))
	return block

def get_key_down(destination,*argl):
	block = [
		(assign,destination,-1),
		(try_begin),
			(eq,1,0),
	]
	for i_key in range(len(KEYBOARD_KEYS)):
		key = KEYBOARD_KEYS[i_key]
		block.append((else_try))
		block.append(	(key_is_down,key))
		block.append(	(assign,destination,key))
	block.append((try_end))
	return block

def is_key_letter(key_no,*argl):
	block = []
	for i_key in range(len(KEYBOARD_KEYS_LETTER)):
		key = KEYBOARD_KEYS_LETTER[i_key]
		if i_key != 0:
			block.append((this_or_next|eq,key_no,key))
	block.append((eq,key_no,KEYBOARD_KEYS_LETTER[0]))
	return block

def is_key_number(key_no,*argl):
	block = []
	for i_key in range(len(KEYBOARD_KEYS_NUM)):
		key = KEYBOARD_KEYS_NUM[i_key]
		if i_key != 0:
			block.append((this_or_next|eq,key_no,key))
	block.append((eq,key_no,KEYBOARD_KEYS_NUM[0]))
	return block

def this_or_next_is_key_letter(key_no,*argl):
	block = []
	for i_key in range(len(KEYBOARD_KEYS_LETTER)):
		key = KEYBOARD_KEYS_LETTER[i_key]
		block.append((this_or_next|eq,key_no,key))
	return block

def this_or_next_is_key_number(key_no,*argl):
	block = []
	for i_key in range(len(KEYBOARD_KEYS_NUM)):
		key = KEYBOARD_KEYS_NUM[i_key]
		block.append((this_or_next|eq,key_no,key))
	return block

extend_syntax(get_key_clicked)               # (get_key_clicked, destination),
extend_syntax(get_key_down)                  # (get_key_down,    destination),
extend_syntax(is_key_letter)                 # (is_key_letter,   key_no),## cf
extend_syntax(is_key_number)                 # (is_key_number,   key_no),## cf
extend_syntax(this_or_next_is_key_letter)    # (this_or_next_is_key_letter,   key_no),## cf
extend_syntax(this_or_next_is_key_number)    # (this_or_next_is_key_number,   key_no),## cf

there's also a dependency on plugin_ms_extensions and plugin_presentations, both of which come with the default WRECK instalation

so, since they released (mission_set_time_speed) and related operations, I've been thinking of a system to issue written commands from inside a mission template, without having your character standing ildly or pausing the game. this could be used for mods that wish to add some kind of magic system, which requires some foreign language to use it, or simply to recognize command line input from the player.

here's what I've come up with so far, it seems to work nicely, the slow-motion fades in and out smoothly and can be easily adjusted:
##removed due to character limit##

on the part of recognizing the input and checking if it is a valid word, I've been thinking of doing some sort of trie, just didnt get around to implementing it(probably with temp troop slots)


EDIT: added a few missing bits I had from another plugin (oops)
EDIT2: I forgot I was using lav's plugin_presentations as well ( :oops:)
 
Were talking about "idea", I was thinking that recently:

There would be a "special hits". With certain hits, time may be slow down for 2-3 secs, a writing may show up in screen btw. During this time, we press to key that we put, when we pressed it, time will flow as normal and we will animate the "special hit" and give damage to agent that we fight.  :fruity:
 
ok, I got the presentation running almost as good as I want and I'm halfway trought creating the system to recognize the words, heres what its looking like so far:
AS02eW5.jpg

the letters appear at a random position when you click them, fully transparent and 4x normal size, then they animate to the correct position size and alpha.
once they are at the correct place, they keep shimering a bit(randomly changing size a bit), but this can be easily disabled

edit:

welp, I got tired of doing the trie way, as I'd need to create it both in python and in the module system(which cant only handle integers, no chars or strings directly) and decided to use the good old brute force metheod
Code:
	("cf_current_word_is_valid",[
		(assign,l.result,1),
		(try_begin),
			(lt,g.ibcc_text,1),
		(else_try),
			(troop_slot_eq,trp.ibcc_temp,0,key_p),
			(try_begin),
				(lt,g.ibcc_text,2),
			(else_try),
				(troop_slot_eq,trp.ibcc_temp,1,key_o),
				(try_begin),
					(lt,g.ibcc_text,3),
				(else_try),
					(troop_slot_eq,trp.ibcc_temp,2,key_t),
					(try_begin),
						(lt,g.ibcc_text,4),
					(else_try),
						(troop_slot_eq,trp.ibcc_temp,3,key_a),
						(try_begin),
							(lt,g.ibcc_text,5),
						(else_try),
							(troop_slot_eq,trp.ibcc_temp,4,key_t),
							(try_begin),
								(lt,g.ibcc_text,6),
							(else_try),
								(troop_slot_eq,trp.ibcc_temp,5,key_o),
								(try_begin),
									(lt,g.ibcc_text,7),
								(else_try),
									(troop_slot_eq,trp.ibcc_temp,6,key_e),
									(try_begin),
										(lt,g.ibcc_text,8),
									(else_try),
										(troop_slot_eq,trp.ibcc_temp,7,key__),
										(try_begin),
											(lt,g.ibcc_text,9),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_t),
											(try_begin),
												(lt,g.ibcc_text,10),
											(else_try),
												(troop_slot_eq,trp.ibcc_temp,9,key_h),
												(try_begin),
													(lt,g.ibcc_text,11),
												(else_try),
													(troop_slot_eq,trp.ibcc_temp,10,key_r),
													(try_begin),
														(lt,g.ibcc_text,12),
													(else_try),
														(troop_slot_eq,trp.ibcc_temp,11,key_o),
														(try_begin),
															(lt,g.ibcc_text,13),
														(else_try),
															(troop_slot_eq,trp.ibcc_temp,12,key_w),
															(lt,g.ibcc_text,14),
														(else_try),
															(assign,l.result,0),
														(try_end),
													(else_try),
														(assign,l.result,0),
													(try_end),
												(else_try),
													(assign,l.result,0),
												(try_end),
											(else_try),
												(assign,l.result,0),
											(try_end),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_m),
											(try_begin),
												(lt,g.ibcc_text,10),
											(else_try),
												(troop_slot_eq,trp.ibcc_temp,9,key_g),
												(lt,g.ibcc_text,11),
											(else_try),
												(assign,l.result,0),
											(try_end),
										(else_try),
											(assign,l.result,0),
										(try_end),
									(else_try),
										(assign,l.result,0),
									(try_end),
								(else_try),
									(assign,l.result,0),
								(try_end),
							(else_try),
								(assign,l.result,0),
							(try_end),
						(else_try),
							(assign,l.result,0),
						(try_end),
					(else_try),
						(assign,l.result,0),
					(try_end),
				(else_try),
					(assign,l.result,0),
				(try_end),
			(else_try),
				(assign,l.result,0),
			(try_end),
		(else_try),
			(assign,l.result,0),
		(try_end),
		(eq,l.result,1),
		]),
 
You could simplify your word recognition (and make it more easily extensible) using WSE's string functions:
Code:
str_equals                                = 2600 #(str_equals, <string_1>, <string_2>, [<case_insensitive>]), #Fails if <string_1> is not equal to <string_2>
str_contains                              = 2601 #(str_contains, <string_1>, <string_2>, [<case_insensitive>]), #Fails if <string_1> doesn't contain <string_2>
str_starts_with                           = 2602 #(str_starts_with, <string_1>, <string_2>, [<case_insensitive>]), #Fails if <string_1> doesn't start with <string_2>
str_ends_with                             = 2603 #(str_ends_with, <string_1>, <string_2>, [<case_insensitive>]), #Fails if <string_1> doesn't end with <string_2>
str_is_alpha                              = 2604 #(str_is_alpha, <string_1>, [<index>]), #Fails if character [<index>] of <string_1> isn't alphabetic. If [<index>] is not defined or is -1, the entire string is checked
str_is_digit                              = 2605 #(str_is_digit, <string_1>, [<index>]), #Fails if character [<index>] of <string_1> isn't a digit. If [<index>] is not defined or is -1, the entire string is checked
str_is_whitespace                         = 2606 #(str_is_whitespace, <string_1>, [<index>]), #Fails if character [<index>] of <string_1> isn't whitespace. If [<index>] is not defined or is -1, the entire string is checked
str_length                                = 2607 #(str_length, <destination>, <string_1>), #Stores the length of <string_1> into <destination>
str_index_of                              = 2608 #(str_index_of, <destination>, <string_1>, <string_2>, [<start>], [<end>]), #Stores the index of the first occurrence of <string_2> in <string_1> into <destination>. Search bounds can be specified with [<start>] and [<end>]
str_last_index_of                         = 2609 #(str_last_index_of, <destination>, <string_1>, <string_2>, [<start>], [<end>]), #Stores the index of the last occurrence of <string_2> in <string_1> into <destination>. Search bounds can be specified with [<start>] and [<end>]
str_get_char                              = 2610 #(str_get_char, <destination>, <string_1>, [<index>]), #Stores the numeric value of the [<index>]th character in <string_1> into <destination>
str_to_num                                = 2611 #(str_to_num, <destination_fixed_point>, <string_1>, [<use_fixed_point_multiplier>]), #Stores the numeric value of <string_1> into <destination_fixed_point>. Decimal values will be rounded to integers, for more precision set [<use_fixed_point_multiplier>] to non-zero
str_compare                               = 2612 #(str_compare, <destination>, <string_1>, <string_2>, [<case_insensitive>]), #Stores the relationship between <string_1> and <string_2> into <destination> (-1: s1 < s2, 0: s1 = s2, 1: s1 > s2)
str_split                                 = 2613 #(str_split, <destination>, <string_register>, <string_1>, <delimiter>, [<skip_empty>], [<max>]), #Splits <string_1> using <delimiter> into a range of string registers, starting from <string_register>, storing [<max>] substrings at most (default = unlimited), ignoring empty (zero length) substrings if [<skip_empty>] (default = false). Stores the amount of substrings split into <destination>
str_sort                                  = 2614 #(str_sort, <string_register>, [<count>], [<case_insensitive>], [<descending>]), #Sorts a range of [<count>] string registers starting from <string_register>
str_store_lower                           = 2615 #(str_store_lower, <string_register>, <string_1>), #Stores the lowercase version of <string_1> into <string_register>
str_store_upper                           = 2616 #(str_store_upper, <string_register>, <string_1>), #Stores the uppercase version of <string_1> into <string_register>
str_store_trim                            = 2617 #(str_store_trim, <string_register>, <string_1>, [<trim_mode>]), #Stores the whitespace trimmed version of <string_1> into <string_register>. [<trim_mode>]: 0 (default) = trim leading and trailing, 1 = trim leading, 2 = trim trailing
str_store_replace                         = 2618 #(str_store_replace, <string_register>, <string_1>, <string_2>, <string_3>), #Stores <string_1> into <string_register>, replacing occurrences of <string_2> with <string_3>
str_store_md5                             = 2619 #(str_store_md5, <string_register>, <string_1>), #MD5 encrypts <string_1> and stores it into <string_register>
str_store_substring                       = 2620 #(str_store_substring, <string_register>, <string_1>, [<start>], [<length>]), #Stores a substring of <string_1> into <string_register>, starting from [<start>]. If [<length>] is not specified, everything on the right of <start> will be used
str_store_reverse                         = 2621 #(str_store_reverse, <string_register>, <string_1>), #Stores the reverse of <string_register> into <string_1>
str_store_join                            = 2622 #(str_store_join, <string_register>, <start_string_register>, <count>, [<delimiter>]), #Joins <count> string registers starting from string register <start_string_register>, using [<delimiter>] (default = empty string) and stores them into <string_register>
str_store_replace_spaces_with_underscores = 2623 #(str_store_replace_spaces_with_underscores, <string_register>, <string_1>), #Stores <string_1> into <string_register>, replacing all spaces with underscores
str_store_replace_underscores_with_spaces = 2624 #(str_store_replace_underscores_with_spaces, <string_register>, <string_1>), #Stores <string_1> into <string_register>, replacing all underscores with spaces
str_store_multiplayer_profile_name        = 2625 #(str_store_multiplayer_profile_name, <string_register>, <profile_no>), #Stores <profile_no>'s name into <string_register>
str_store_face_keys                       = 2626 #(str_store_face_keys, <string_register>, <face_key_register>), #Stores the string representation of <face_key_register> into <string_register>
str_store_module_setting                  = 2627 #(str_store_module_setting, <string_register>, <setting>), #Stores the string value (empty if not found) of <setting> in module.ini into <string_register>
str_store_server_password_admin           = 2628 #(str_store_server_password_admin, <string_register>), #Stores the server administrator password into <string_register>
str_store_server_password_private         = 2629 #(str_store_server_password_private, <string_register>), #Stores the server private player password into <string_register>
str_store_overlay_text                    = 2630 #(str_store_overlay_text, <string_register>, <overlay_no>), #Stores <overlay_no>'s text into <string_register>
str_store_player_ip                       = 2631 #(str_store_player_ip, <string_register>, <player_no>), #Stores <player_no>'s IP address into <string_register> (works only on servers)
str_store_game_variable                   = 2632 #(str_store_game_variable, <string_register>, <variable>), #Stores the string value (empty if not found) of <variable> in game_variables.txt into <string_register>
str_store_skill_name                      = 2633 #(str_store_skill_name, <string_register>, <skill_no>), #Stores the name of <skill_no> into <string_register>
str_store_float                           = 2634 #(str_store_float, <string_register>, <fp_register>, [<precision>]), #Stores the string representation of <fp_register> into <string_register> showing [<precision>] decimal digits at most
str_sanitize                              = 2635 #(str_sanitize, <string_register>), #Removes invalid characters from <string_register>
str_store_item_id                         = 2636 #(str_store_item_id, <string_register>, <item_no>), #Stores the id of <item_no> into <string_register>
str_is_integer                            = 2637 #(str_is_integer, <string_1>), #Fails if <string_1> isn't a valid integer
 
yeah, but I'm trying to stay away from WSE for this. tought I remember someone saying that we could use face code operations to handle strings now
 
Im almost done with it, just doing some final testing:
Code:
from compiler import *
register_plugin()

## in-batle command callig ---- TESTING

ibcc_max_slow_duration = 8#second
ibcc_max_slow          = 100#/1000 of normal speed
ibcc_slow_fade_time    = 4#seconds it takes to go back to normal speed after ibcc_max_slow_duration

presentations = [
	("ibcc_type",prsntf_read_only,0,[
		(ti_on_presentation_load,[
			(set_fixed_point_multiplier,1000),
			(presentation_set_duration, 100000000),
			(assign,g.ibcc_text_x,50),
			(assign,g.ibcc_text,-1),
			(assign,g.ibcc_prsnt_state,1),
			(ui_create_textbox, g.ibcc_bg2, 1000, 1000, 1, 1),
			(ui_create_mesh, g.ibcc_bg1, mesh.inv_slot, 0, 0, 12*1000, 12*750),
			(overlay_set_color, g.ibcc_bg1, 0x000000),
			(overlay_set_alpha, g.ibcc_bg1, 0x00),
			(overlay_animate_to_alpha, g.ibcc_bg1, ibcc_max_slow_duration * ibcc_max_slow, 0xbf),#fade in while its on max slow
			(mission_set_time_speed,ibcc_max_slow),
			]),
		(ti_on_presentation_run,[
			(set_fixed_point_multiplier,1000),
			(store_trigger_param_1,l.time),
			(overlay_obtain_focus, g.ibcc_bg2),#to prevent warband hardcoded screens from interupting the typing
			(try_begin),
				(this_or_next|eq,g.ibcc_prsnt_state,-1),
				(eq,g.ibcc_prsnt_state,2),
				#(ge,l.time,(ibcc_max_slow_duration + ibcc_slow_fade_time) * ibcc_max_slow),
				(ge,l.time,(ibcc_max_slow_duration + ibcc_slow_fade_time) * 1000),
				(assign,g.ibcc_prsnt_state,-1),
				#(display_message,"@ending prsnt"),
				(mission_time_speed_move_to_value,1000,1000),
				(presentation_set_duration,0),
			(else_try),
				(eq,g.ibcc_prsnt_state,1),
				#(ge,l.time,ibcc_max_slow_duration * ibcc_max_slow),
				(ge,l.time,ibcc_max_slow_duration * 1000),
				(assign,g.ibcc_prsnt_state,2),
				#(display_message,"@decreasing slow"),
				(overlay_animate_to_alpha, g.ibcc_bg1, ibcc_slow_fade_time * ibcc_max_slow, 0x00),#fade out with the slow
				(mission_time_speed_move_to_value,1000,ibcc_slow_fade_time * ibcc_max_slow),
			(try_end),
			(get_key_clicked, l.key),
			(try_begin),
				(eq,l.key,-1),
			(else_try),
				(eq,l.key,key_z),
				(eq,g.ibcc_text,-1),
				(assign,g.ibcc_text,0),
			(else_try),
				(eq,l.key,key_enter),
				#(display_message,"@Clicked enter"),
				(call_script,script.current_word_apply),## you can use this to apply negative or lessened effects when you misscast something
				(assign,g.ibcc_prsnt_state,-1),
				(mission_time_speed_move_to_value,1000,1000),
				(overlay_animate_to_alpha, g.ibcc_bg1, 1000, 0x00),#fade out with the slow
			(else_try),
				(call_script,script.get_key_name,l.key),
				(eq,l.key,key_space),
				(str_store_string,s1,"@ "),
				(eq,1,0),
			(else_try),
				(this_or_next_is_key_letter,l.key),
				(this_or_next_is_key_number,l.key),
				(eq,l.key,key_space),
				(store_random_in_range,l.x,0,1000),
				(store_random_in_range,l.y,0,750),
				(ui_create_label,l.overlay,s1,l.x,l.y,0,4000),
				(overlay_set_alpha, l.overlay, 0x00),
				(overlay_animate_to_alpha, l.overlay, 1000, 0xbf),#fade in
				(position_set_x,pos1,1000),
				(position_set_y,pos1,1000),
				(overlay_animate_to_size, l.overlay, 1000, pos1),
				(position_set_x,pos1,g.ibcc_text_x),
				(position_set_y,pos1,500),
				(overlay_animate_to_position, l.overlay, 1000, pos1),
				(val_add,g.ibcc_text_x,20),
				(troop_set_slot,trp.ibcc_temp,g.ibcc_text,l.key),##save the word to ibcc_temp
				(troop_set_slot,trp.ibcc_temp,g.ibcc_text+1,-1),##just to be sure
				(val_add,g.ibcc_text,1),
				#(call_script,script.get_key_name,l.key),
				#(display_message,"@Clicked {s1}"),
			(try_end),
			###comment this part out if you dont want to break the prsntation as soon as the word is invalid
			(try_begin),
				(call_script,script.cf_current_word_is_valid),##check if using the current word you can write a valid one
			(else_try),
				(call_script,script.current_word_apply),## you can use this to apply negative or lessened effects when you misscast something
				##TODO: make some sort of breaking mesh animation and display a message
				(assign,g.ibcc_prsnt_state,3),
				(mission_time_speed_move_to_value,1000,1),
			(try_end),
			###comment this part out if you want your leters to stay static at the screen
			(try_for_range,l.overlay,g.ibcc_bg1+1,g.ibcc_bg1+1+g.ibcc_text),
				## make them change size at irregular intervals
				(store_mod,l.temp1,l.overlay,10),
				(store_mod,l.temp2,l.time,10),
				(eq,l.temp1,l.temp2),
				##
				(store_random_in_range,l.x,900,1100),
				(store_random_in_range,l.y,900,1100),
				(position_set_x,pos1,l.x),
				(position_set_y,pos1,l.y),
				(overlay_animate_to_size, l.overlay, 1000, pos1),
			(try_end),
			]),
		]),
]

troops = [
	["ibcc_temp","temp","temp",tf_hero,0,0,0,[],0,0,0,0],
]

scripts = [
	("cf_current_word_is_valid",[
		(assign,l.result,1),
		(try_begin),
			(lt,g.ibcc_text,1),
		(else_try),
			(troop_slot_eq,trp.ibcc_temp,0,key_p),
			(try_begin),
				(lt,g.ibcc_text,2),
			(else_try),
				(troop_slot_eq,trp.ibcc_temp,1,key_o),
				(try_begin),
					(lt,g.ibcc_text,3),
				(else_try),
					(troop_slot_eq,trp.ibcc_temp,2,key_t),
					(try_begin),
						(lt,g.ibcc_text,4),
					(else_try),
						(troop_slot_eq,trp.ibcc_temp,3,key_a),
						(try_begin),
							(lt,g.ibcc_text,5),
						(else_try),
							(troop_slot_eq,trp.ibcc_temp,4,key_t),
							(try_begin),
								(lt,g.ibcc_text,6),
							(else_try),
								(troop_slot_eq,trp.ibcc_temp,5,key_o),
								(try_begin),
									(lt,g.ibcc_text,7),
								(else_try),
									(troop_slot_eq,trp.ibcc_temp,6,key_space),
									(try_begin),
										(lt,g.ibcc_text,8),
									(else_try),
										(troop_slot_eq,trp.ibcc_temp,7,key_t),
										(try_begin),
											(lt,g.ibcc_text,9),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_h),
											(try_begin),
												(lt,g.ibcc_text,10),
											(else_try),
												(troop_slot_eq,trp.ibcc_temp,9,key_r),
												(try_begin),
													(lt,g.ibcc_text,11),
												(else_try),
													(troop_slot_eq,trp.ibcc_temp,10,key_o),
													(try_begin),
														(lt,g.ibcc_text,12),
													(else_try),
														(troop_slot_eq,trp.ibcc_temp,11,key_w),
														(lt,g.ibcc_text,13),
													(else_try),
														(assign,l.result,0),
													(try_end),
												(else_try),
													(assign,l.result,0),
												(try_end),
											(else_try),
												(assign,l.result,0),
											(try_end),
										(else_try),
											(assign,l.result,0),
										(try_end),
									(else_try),
										(troop_slot_eq,trp.ibcc_temp,7,key_m),
										(try_begin),
											(lt,g.ibcc_text,9),
										(else_try),
											(troop_slot_eq,trp.ibcc_temp,8,key_g),
											(lt,g.ibcc_text,10),
										(else_try),
											(assign,l.result,0),
										(try_end),
									(else_try),
										(assign,l.result,0),
									(try_end),
								(else_try),
									(assign,l.result,0),
								(try_end),
							(else_try),
								(assign,l.result,0),
							(try_end),
						(else_try),
							(assign,l.result,0),
						(try_end),
					(else_try),
						(assign,l.result,0),
					(try_end),
				(else_try),
					(assign,l.result,0),
				(try_end),
			(else_try),
				(assign,l.result,0),
			(try_end),
		(else_try),
			(assign,l.result,0),
		(try_end),
		(try_begin),
			(eq,l.result,0),
			(str_store_string,s0,"@check failed on "),
			(assign,l.temp,1),
			(try_for_range,l.slot,0,l.temp),
				(neg|troop_slot_eq,trp.ibcc_temp,l.slot+1,-1),
				(val_add,l.temp,1),
				(troop_get_slot,l.key,trp.ibcc_temp,l.slot),
				(call_script,script.get_key_name,l.key),
				(str_store_string,s0,"@{s0}{s1}"),
				(neg|troop_slot_eq,trp.ibcc_temp,l.slot+2,-1),
				(str_store_string,s0,"@{s0}, "),
			(try_end),
			(display_message,s0),
		(try_end),
		(eq,l.result,1),
		]),
	("current_word_apply",[
		(try_begin),
			(troop_slot_eq,trp.ibcc_temp, 0,key_p),
			(troop_slot_eq,trp.ibcc_temp, 1,key_o),
			(troop_slot_eq,trp.ibcc_temp, 2,key_t),
			(troop_slot_eq,trp.ibcc_temp, 3,key_a),
			(troop_slot_eq,trp.ibcc_temp, 4,key_t),
			(troop_slot_eq,trp.ibcc_temp, 5,key_o),
			(troop_slot_eq,trp.ibcc_temp, 6,key_space),
			(troop_slot_eq,trp.ibcc_temp, 7,key_t),
			(troop_slot_eq,trp.ibcc_temp, 8,key_h),
			(troop_slot_eq,trp.ibcc_temp, 9,key_r),
			(troop_slot_eq,trp.ibcc_temp,10,key_o),
			(troop_slot_eq,trp.ibcc_temp,11,key_w),
			(troop_slot_eq,trp.ibcc_temp,12,-1),
			(assign,g.throw_potatoes,1),
		(try_end),
		(try_begin),
			(troop_slot_eq,trp.ibcc_temp, 0,key_p),
			(troop_slot_eq,trp.ibcc_temp, 1,key_o),
			(troop_slot_eq,trp.ibcc_temp, 2,key_t),
			(troop_slot_eq,trp.ibcc_temp, 3,key_a),
			(troop_slot_eq,trp.ibcc_temp, 4,key_t),
			(troop_slot_eq,trp.ibcc_temp, 5,key_o),
			(troop_slot_eq,trp.ibcc_temp, 6,key_space),
			(troop_slot_eq,trp.ibcc_temp, 7,key_m),
			(troop_slot_eq,trp.ibcc_temp, 8,key_g),
			(troop_slot_eq,trp.ibcc_temp, 9,-1),
			(assign,g.throw_potatoes,100),
		(try_end),
		]),
]

items = [
	["potato_bow","Potato Bow", [("hunting_bow",0), ("hunting_bow_carry",ixmesh_carry)], itp_type_bow |itp_primary|itp_two_handed,itcf_shoot_bow|itcf_carry_bow_back, 0, weight(1.5)|spd_rtng(90) | shoot_speed(40) | thrust_damage(1, blunt),0],
	["potatoes","Potatoes", [("throwing_stone",0),("throwing_stone",ixmesh_flying_ammo)], itp_type_arrows, itcf_carry_quiver_back, 0,weight(1.5)|weapon_length(95)|max_ammo(80),0],
]

injection = {
	'ibcc_triggers' : [##mission templates
		(0.1,0,3,[
			(neg|main_hero_fallen),
			(ge,g.throw_potatoes,1),
			#(display_message,"@Firing potato!!"),
			(val_sub,g.throw_potatoes,1),
			(get_player_agent_no,l.agent),
			(set_fixed_point_multiplier,1000),
			####(agent_get_bone_position, pos1, l.agent, 9),#get head level, in case player is on horse or jumping ## not working properly when jumping on a horse
			####(position_get_distance_to_ground_level,l.dist,pos1),
			(agent_get_position, pos1, l.agent),
			####(position_move_z, pos1, l.dist, 1),
			(try_begin),
				(agent_get_horse,l.horse,l.agent),
				(agent_is_active,l.horse),
				(agent_is_alive,l.horse),
				(position_move_z, pos1, 50, 1),
			(try_end),
			(position_move_z, pos1, 200, 1),
			(position_move_y, pos1, 5, 0),
			(add_missile,l.agent,pos1,10000,itm.potato_bow,0,itm.potatoes,0),
			#(set_spawn_position, pos1),
			#(spawn_item, itm.potato_bow),
			(lt,g.throw_potatoes,1),
		],[]),
		(0,0,5,[
			(neg|main_hero_fallen),
			(key_clicked,g.ibcc_hotkey),
			(neg|is_presentation_active,prsnt.ibcc_type),
			(eq,g.ibcc_prsnt_state,-1),
			(assign,g.ibcc_prsnt_state,0),
			(start_presentation,prsnt.ibcc_type),
		],[]),
		(1,0,10,[##this is here due to (presentation_set_duration) working on all active and messing up with mission speed
			(is_presentation_active,prsnt.ibcc_type),
			(eq,g.ibcc_prsnt_state,-1),
			(presentation_set_duration,0),
			(set_fixed_point_multiplier,1000),
			(mission_time_speed_move_to_value,1000,1000),
		],[]),
		(1,0,10,[##this is here due to (presentation_set_duration) working on all active and messing up with mission speed
			(neg|is_presentation_active,prsnt.ibcc_type),
			(neq,g.ibcc_prsnt_state,-1),
			(assign,g.ibcc_prsnt_state,-1),
			(set_fixed_point_multiplier,1000),
			(mission_time_speed_move_to_value,1000,1000),
		],[]),
	],
	'inject_game_start' : [
		(assign,g.ibcc_prsnt_state,-1),
	],
}

maybe I'll try to auto-generate script.cf_current_word_is_valid, because its a hassle to add new words in there





Ok, just finished it, did the final tests and made a bit of code to auto-gen script.cf_current_word_is_valid, updated main post with the full code
 
Back
Top Bottom