- 好友
- 6
- 在线时间
- 0 小时
- 最后登录
- 2025-2-26
骑士
 
- UID
- 3398051
- 第纳尔
- 1850
- 精华
- 0
- 互助
- 48
- 荣誉
- 5
- 贡献
- 10
- 魅力
- 341
- 注册时间
- 2022-8-13
 鲜花( 58)  鸡蛋( 0)
|
发表于 2023-8-7 14:28:20
|
显示全部楼层
斗胆献丑了,补充了下,不完美啊,性能还需拆分操作优化,我写一起,做个备忘script.py部分
#script_cf_item_is_missile
#return if item is missile
#INPUT: param1 = item_id
#OUTPUT: boolean
("cf_item_is_missile",
[
(store_script_param, ":item_id", 1),
(assign, ":result",1),
(try_begin),
(item_get_type, ":item_type", ":item_id"),
(neq,":item_type",itp_type_thrown),
(neq,":item_type",itp_type_arrows),
(neq,":item_type",itp_type_bolts),
(neq,":item_type",itp_type_bullets),
(assign, ":result",0),
(try_end),
(eq, ":result", 1),
]),
#script_cf_agent_has_ammo
#return if agent has right ammo
#INPUT: param1 = agent_no
#OUTPUT: false = have space without ammo,true = have ammo
("cf_agent_has_ammo",
[
(store_script_param, ":agent_no", 1),
(agent_get_slot, ":ranged_weapon", ":agent_no", slot_agent_ranged_weapon),
(assign, ":result", 1),
(try_for_range, ":item", 0, 4),
(agent_get_item_slot, ":item_id", ":agent_no", ":item"),
(try_begin),
(eq, ":item_id", -1),
(assign, ":result", 0),
(else_try),
(item_get_type, ":item_type", ":item_id"),
(item_slot_eq, ":ranged_weapon", slot_ranged_weapon_ammo_type, ":item_type"),
(assign, ":result", 1),
(try_end),
(try_end),
(eq, ":result", 1),
]),
game_start添加
#Items:
(try_for_range, ":item_id", all_items_begin, all_items_end),
(item_get_type, ":item_type", ":item_id"),
(try_begin),
(eq, ":item_type", itp_type_bow),
(item_set_slot, ":item_id", slot_ranged_weapon_ammo_type, itp_type_arrows),
(else_try),
(eq, ":item_type", itp_type_crossbow),
(item_set_slot, ":item_id", slot_ranged_weapon_ammo_type, itp_type_bolts),
(else_try),
(eq, ":item_type", itp_type_thrown),
(item_set_slot, ":item_id", slot_ranged_weapon_ammo_type, itp_type_thrown),
(try_end),
(try_end),
# Troops:
# Assign banners and renown.
costants.py添加红色(部分已位于文件中,方便搜索)
slot_item_multiplayer_item_class = 60 #temporary, can be moved to higher values
slot_item_multiplayer_availability_linked_list_begin = 61 #temporary, can be moved to higher value
slot_ranged_weapon_ammo_type =62#0 for non-ranged weapons
########################################################
## AGENT SLOTS #############################
########################################################
........
slot_agent_ranged_weapon = 28
########################################################
## FACTION SLOTS #############################
########################################################
heard_common.py添加
#object types for "try_for_prop_instances" operation
somt_object = 1 # Scene props (Edit mode placement)
somt_entry = 2 # Entry points
somt_item = 3 # Scene items (Edit mode placement)
somt_baggage = 4 # Containers like boxes?
somt_flora = 5 # Plants (trees, rocks, ...)
somt_passage = 6 # Passages
somt_spawned_item = 7 # Spawned items (Player discarded)
somt_spawned_single_ammo_item = 8 # Spawned items (Ammunition spawns when hit)
somt_spawned_unsheathed_item = 9 # Spawned items Other dead agent drops
somt_shield = 10 # shield
somt_temporary_object = 11 # temp
missson_templates.py添加
ai_pick_up_ammo = (
3, 0, 0, [(neg|all_enemies_defeated),],
[
(try_for_range, ":item_id", all_items_begin, all_items_end),
(call_script, "script_cf_item_is_missile", ":item_id"),
(try_begin),
(scene_spawned_item_get_num_instances, ":instance_number", ":item_id"),
(gt, ":instance_number", 0),
(item_get_type, ":item_type", ":item_id"),
(try_for_range, ":index", 0, ":instance_number"),
(scene_spawned_item_get_instance, ":instance", ":item_id", ":index"),
(prop_instance_get_position, pos10, ":instance"),
(position_set_z_to_ground_level, pos10),
(assign,":run",1),
(try_for_agents, ":agent_no", pos10, 300),
(eq,":run",1),
(agent_is_alive, ":agent_no"),
(agent_is_human, ":agent_no"),
(agent_get_slot, ":ranged_weapon", ":agent_no", slot_agent_ranged_weapon),
(gt, ":ranged_weapon", 0),
(agent_is_non_player, ":agent_no"),
(agent_slot_eq, ":agent_no", slot_agent_is_running_away, 0),
(agent_get_horse, ":horse", ":agent_no"),
(eq, reg1, ":horse"),
# (agent_get_combat_state, reg1, ":agent_no"),#
# (neq, reg1, 3),
# (neq, reg1, 4),
# (agent_get_slot, ":ranged_weapon", ":agent_no", slot_agent_ranged_weapon),#
(agent_get_ammo, ":ammo", ":agent_no", 0),
(item_slot_eq, ":ranged_weapon", slot_ranged_weapon_ammo_type, ":item_type"),
(try_begin),
(eq, ":item_type", itp_type_thrown),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(store_skill_level, ":troop_skl", "skl_power_throw", ":troop_no"),
(item_get_difficulty, ":item_skl", ":item_id"),
# (this_or_next|le, ":ammo", 2),
(lt, ":troop_skl", ":item_skl"),
(else_try),
(agent_set_crouch_mode, ":agent_no", 1),
(try_begin),
(call_script, "script_cf_agent_has_ammo", ":agent_no"),
(agent_refill_ammo, ":agent_no"),
(else_try),
(agent_equip_item, ":agent_no", ":item_id"),
(try_end),
(scene_prop_set_prune_time, ":instance", 0),
(assign,":run",0),
(try_end),
(try_end),
(try_end),
(try_end),
(try_for_prop_instances, ":instance", ":item_id", somt_spawned_single_ammo_item),#
(prop_instance_is_valid, ":instance"),
(prop_instance_get_position, pos10, ":instance"),
(position_move_y, pos10, 50, 0),
(position_set_z_to_ground_level, pos10),
(assign,":run",1),
(try_for_agents, ":agent_no", pos10, 300),
(eq,":run",1),
(agent_is_alive, ":agent_no"),
(agent_is_human, ":agent_no"),
(agent_get_slot, ":ranged_weapon", ":agent_no", slot_agent_ranged_weapon),
(gt, ":ranged_weapon", 0),
(agent_is_non_player, ":agent_no"),
(agent_slot_eq, ":agent_no", slot_agent_is_running_away, 0),
(agent_get_horse, ":horse", ":agent_no"),
(eq, ":horse", -1),
# (agent_get_combat_state, reg1, ":agent_no"),
# (neq, reg1, 3),
# (neq, reg1, 4),
# (agent_get_ammo, ":ammo", ":agent_no", 0),
# (le, ":ammo", 10),
(item_slot_eq, ":ranged_weapon", slot_ranged_weapon_ammo_type, ":item_type"),
(try_begin),
(eq, ":item_type", itp_type_thrown),
(agent_get_troop_id, ":troop_no", ":agent_no"),
(store_skill_level, ":troop_skl", "skl_power_throw", ":troop_no"),
(item_get_difficulty, ":item_skl", ":item_id"),
# (this_or_next|le, ":ammo", 2),
(lt, ":troop_skl", ":item_skl"),
(else_try),
(agent_set_crouch_mode, ":agent_no", 1),
(try_begin),
(call_script, "script_cf_agent_has_ammo", ":agent_no"),
(val_add, ":ammo", 1),
(agent_set_ammo, ":agent_no", ":item_id", ":ammo"),
(else_try),
(agent_equip_item, ":agent_no", ":item_id"),
(agent_set_ammo, ":agent_no", ":item_id", 1),
(try_end),
(scene_prop_set_prune_time, ":instance", 0),
(assign,":run",0),
(try_end),
(try_end),
(try_end),
(try_end),
])
free_order_begin = (ti_once, 0, 0, [],
[
(try_for_agents, ":agent"),#get agent_ranged_weapon
(agent_set_slot,":agent",slot_agent_ranged_weapon,0),
(agent_get_wielded_item, ":item_id", ":agent"),
(item_get_type, ":item_type", ":item_id"),
(try_begin),
(eq,":item_type",itp_type_thrown),
(agent_set_slot,":agent",slot_agent_ranged_weapon,":item_id"),
(else_try),
(eq,":item_type",itp_type_bow),
(agent_set_slot,":agent",slot_agent_ranged_weapon,":item_id"),
(else_try),
(eq,":item_type",itp_type_crossbow),
(agent_set_slot,":agent",slot_agent_ranged_weapon,":item_id"),
(try_end),
(try_end),
])
|
|