本帖最后由 Borr 于 2014-12-24 18:34 编辑
#2 将pos旋转至与场景地表垂直的代码。
ms没有自带这个功能。scene_prop刷出来是水平的,如果悬空了很难看。 用这个代码就可以把物品的pos旋转到和地面垂直的法线方向。
.....使用实例:
(prop_instance_get_position, pos10, ":prop"),
(call_script,"script_bf_rotate_pos_to_terrain_normal_direction_pos1",pos10,0,0),
(copy_position,pos10,pos1),
(prop_instance_animate_to_position, ":prop", pos10, 移动时间),
(prop_instance_rotate_to_position, ":prop", pos10, 旋转时间),
当然,也可以先旋转再刷物品,就不需要最后两步了。
.....核心代码就是这个bf_rotate_pos_to_terrain_normal_direction_pos1,
第一参量是pos的编号(要旋转的pos,旋转过的返回到pos1里,不覆盖原pos)
第二参量是x轴反转
第三参量是y轴反转
xy反转可设为0(不反转)或者1(反转)。原因是有些模型的方向和pos的xy指向是反的,这样可以增加自由度。
这个script会覆盖掉pos1和pos2的内容。
("bf_rotate_pos_to_terrain_normal_direction_pos1",
[ (store_script_param, ":pos_num",1),
(store_script_param, ":xflip",2),
(store_script_param, ":yflip",3),
(set_fixed_point_multiplier, 100),
(copy_position,pos1,":pos_num"),
(position_set_z_to_ground_level, pos1),
#--terrain
##
(copy_position,pos2,pos1),
(position_move_x,pos2,100),
(position_set_z_to_ground_level, pos2),
(position_get_z,":zx",pos2),
##
(copy_position,pos2,pos1),
(position_move_x,pos2,-100),
(position_set_z_to_ground_level, pos2),
(position_get_z,":zxm",pos2),
##
(copy_position,pos2,pos1),
(position_move_y,pos2,100),
(position_set_z_to_ground_level, pos2),
(position_get_z,":zy",pos2),
##
(copy_position,pos2,pos1),
(position_move_y,pos2,-100),
(position_set_z_to_ground_level, pos2),
(position_get_z,":zym",pos2),
#---current rotation,
##
(copy_position,pos2,pos1),
(position_move_x,pos2,100),
(position_get_z,":rzx",pos2),
##
(copy_position,pos2,pos1),
(position_move_x,pos2,-100),
(position_get_z,":rzxm",pos2),
##
(copy_position,pos2,pos1),
(position_move_y,pos2,100),
(position_get_z,":rzy",pos2),
##
(copy_position,pos2,pos1),
(position_move_y,pos2,-100),
(position_get_z,":rzym",pos2),
(store_sub,":zxdiff",":zx",":zxm"),
(store_sub,":zydiff",":zy",":zym"),
(store_sub,":rzxdiff",":rzx",":rzxm"),
(store_sub,":rzydiff",":rzy",":rzym"),
#---relative angle between current orientation and terrain orietation.
(val_sub,":zxdiff",":rzxdiff"),
(val_sub,":zydiff",":rzydiff"),
(store_atan2,":angx100",":zxdiff",200),
(store_atan2,":angy100",":zydiff",200),
##
(store_div,":angx",":angx100",100),
(store_div,":angy",":angy100",100),
#
(try_begin),
(eq,":xflip",1),
(val_mul,":angx",-1),
(try_end),
(try_begin),
(eq,":yflip",1),
(val_mul,":angy",-1),
(try_end),
#
(position_rotate_y,pos1,":angx"),
(position_rotate_x,pos1,":angy"),
]),
|
#1 在场景里刷无马骑兵的代码。
原理很简单,就是在module_troop.py定义一个备份物品栏用的新的兵种,trp_bf_temp,然把要刷的兵种的物品栏存入这个备用的trp_bf_temp,再清除的刷出兵种的马匹,刷兵,最后还原物品栏。 这个代码每次刷兵到要执行一次。 当然各位也可以修改下变成一个script。
(set_spawn_position,pos1), #预定在pos1位置刷出":troop"
(call_script,"script_bf_troop_clear_horses",":troop"), #把":troop"物品栏存入一个备用的:troop,清除:troop的马匹,然后再刷agent
(spawn_agent,":troop"),
(call_script,"script_bf_troop_refill_inv_from_temp",":troop"), #再把备份的物品栏还原到:troop
|
红色部分按照mod物品自行更改
("bf_troop_clear_horses",
[
(store_script_param_1, ":troop"),
(troop_set_auto_equip,":troop",0),
# clear all for the tmp_troop
(troop_get_inventory_capacity, ":capacity", "trp_bf_temp"),
(try_for_range, ":inventory_slot", 0, ":capacity"),
(troop_set_inventory_slot, "trp_bf_temp", ":inventory_slot",-1),
(try_end),
# now, copy the target troop inventory to tmp
(troop_get_inventory_capacity, ":capacity", ":troop"),
(try_for_range, ":islot", 0, ":capacity"),
(troop_get_inventory_slot,":item", ":troop", ":islot"),
(gt,":item",0),
(troop_set_inventory_slot, "trp_bf_temp", ":islot",":item"),
(try_end),
# now clear out the troop's inv
#(troop_get_inventory_capacity, ":capacity", ":troop"),
(try_for_range, ":islot", 0, ":capacity"),
(troop_set_inventory_slot,":troop", ":islot",-1),
(try_end),
# now put back the troop's items, only if not horse.
(try_for_range, ":islot", 0, ":capacity"),
(troop_get_inventory_slot,":item","trp_bf_temp", ":islot"),
# if it is a horse, remove from the original troop
# test: all items, complete rip-off
(gt,":item",0),
(neg|is_between,":item","itm_马匹开始","itm_马匹结束"),
(troop_add_item, ":troop", ":item"),
(try_end),
(troop_equip_items, ":troop"),
]),
("bf_troop_refill_inv_from_temp",
[
(store_script_param_1, ":troop"),
# now, copy the target troop inventory to tmp
(troop_get_inventory_capacity, ":capacity", ":troop"),
(try_for_range, ":islot", 0, ":capacity"),
(troop_get_inventory_slot,":item", "trp_bf_temp", ":islot"),
(gt,":item",0),
# just copy all of them back
(troop_set_inventory_slot, ":troop", ":islot",":item"),
(try_end),
(troop_sort_inventory,":troop"),
(troop_equip_items, ":troop"),
(troop_set_auto_equip,":troop",1),
]),
|
|