add_missile for WFaS

正在查看此主题的用户

DoDoCat

Squire
Hey, I am trying to make`add_missile` operation workable for WFaS

Here are my codes:

module_scripts.py:
插入代码块:
	("add_missile_init",
	[
		(try_for_range, ":current_idx" , 0, 1024),
			(troop_set_slot, "trp_add_missile_agent_array", ":current_idx", -1),
			(troop_set_slot, "trp_add_missile_item_array", ":current_idx", -1),
			(troop_set_slot, "trp_add_missile_speed_array", ":current_idx", -1),
		(try_end),
	]),
	
	("add_missile",
	[
		(store_script_param, ":agent_id", 1),
		(store_script_param, ":starting_postion", 2),
		(store_script_param, ":starting_speed_fixed_point", 3),
		#(store_script_param, ":weapon_item_id", 4),
		#(store_script_param, ":weapon_item_modifier", 5),
		(store_script_param, ":scene_prop_id", 4),
		
		(set_spawn_position, ":starting_postion"),
		(spawn_scene_prop, ":scene_prop_id"),
		(assign, ":missile_item_id", reg0),
		
		(call_script, "script_get_next_idx", "trp_add_missile_agent_array", -1),
		(assign, ":add_missile_array_next_index", reg0),
		(call_script, "script_get_next_idx", "trp_add_missile_item_array", -1),
		(assign, ":add_missile_item_next_index", reg0),
		(call_script, "script_get_next_idx", "trp_add_missile_speed_array", -1),
		(assign, ":add_missile_speed_next_index", reg0),
		
		(troop_set_slot, "trp_add_missile_agent_array", ":add_missile_array_next_index",":agent_id"),
		(troop_set_slot, "trp_add_missile_item_array", ":add_missile_item_next_index", ":missile_item_id"),
		(troop_set_slot, "trp_add_missile_speed_array", ":add_missile_speed_next_index", ":starting_speed_fixed_point"),
	]),
	
	("get_next_idx", 
	[
		(store_script_param, ":troop_id", 1),
		(store_script_param, ":end_symbol", 2),
		
		(assign, ":end_cond", 1024),
		(try_for_range, ":current_idx", 0, ":end_cond"),
			(troop_get_slot, ":value", ":troop_id", ":current_idx"),
			(try_begin),
				(eq, ":value", ":end_symbol"),
				(assign, reg0, ":current_idx"),
				(display_message, "@CURRENT INDEX IS: {reg0}"),
				(assign, ":end_cond", 0),#break
			(try_end),
		(try_end),
	]),

module_missile_templates.py
插入代码块:
add_missile_simulate = (
	1, 0, 0,[],
	[
		(assign, ":end_cond", 1024),
		(try_for_range, ":current_idx", 0, ":end_cond"),
			(troop_get_slot, ":missile_attacker_id", "trp_add_missile_agent_array", ":current_idx"),
			(troop_get_slot, ":missile_scene_prop_id", "trp_add_missile_item_array", ":current_idx"),
			(troop_get_slot, ":missile_speed", "trp_add_missile_speed_array", ":current_idx"),
			
			(try_begin),
				(eq, ":missile_attacker_id", -1),
				(eq, ":missile_scene_prop_id", -1),
				(eq, ":missile_speed", -1),
				(assign, ":end_cond", 0),#break
			(else_try),
				(assign, ":distance_x", ":missile_speed"),
				(assign, ":distance_y", ":missile_speed"),
				(assign, ":distance_z", ":missile_speed"),
				(prop_instance_get_position, pos11, ":missile_scene_prop_id"),
				(position_get_rotation_around_x, ":x_rotate", pos11),
				(position_get_rotation_around_y, ":y_rotate", pos11),
				(position_get_rotation_around_z, ":z_rotate", pos11),
				(store_cos, ":distance_x", ":x_rotate"),
				(store_cos, ":distance_y", ":y_rotate"),
				(store_cos, ":distance_z", ":z_rotate"),
				
				(assign, reg0, ":x_rotate"),
				(display_message, "@ANGLE X: {reg0}"),
				(assign, reg0, ":y_rotate"),
				(display_message, "@ANGLE Y: {reg0}"),
				(assign, reg0, ":z_rotate"),
				(display_message, "@ANGLE Z: {reg0}"),
				(copy_position, pos12, pos11),
				
				#(position_move_x, pos11, ":distance_x"),
				(position_move_y, pos12, ":missile_speed"),
				#(position_move_z, pos11, ":distance_z"),
				
				(val_mul, ":missile_speed", 100),
				(prop_instance_set_position, ":missile_scene_prop_id", pos12),
			(try_end),
		(try_end),
	]
)

This code seems can't work, especially the move the missile
插入代码块:
(prop_instance_set_position, ":missile_scene_prop_id", pos12),

Any Ideas?

 
If I remember correctly, you don’t move a scene prop missile you spawn new instances of the prop in new locations to simulate movement. Have a look at Dr Tomas’s cannon code in the OSP Warband mod Twilight of the Sun King.
https://forums.taleworlds.com/index.php/topic,342969.0.html
It’s a long time since I added Dr Tomas’s cannon code to my WFaS mod, so my memory may be incorrect. However, his code should be convertable
 
NPC99 说:
If I remember correctly, you don’t move a scene prop missile you spawn new instances of the prop in new locations to simulate movement. Have a look at Dr Tomas’s cannon code in the OSP Warband mod Twilight of the Sun King.
https://forums.taleworlds.com/index.php/topic,342969.0.html
It’s a long time since I added Dr Tomas’s cannon code to my WFaS mod, so my memory may be incorrect. However, his code should be convertable
Thanks, it is very useful! I will update the code when I finish testing!

The tank will income when this code finished :smile:
 
后退
顶部 底部