---------------------------------------------------------------------------------------------------------------------- -- Менеджер изменения состояния тела -- автор: Диденко Руслан (Stohe) -- перехерячивал: Пличко Александр (Plecha) -- TODO: ---------------------------------------------------------------------------------------------------------------------- --function printf() --end --' Сам менеджер function goap_graph(st, npc) st.npc = npc st.planner = action_planner() st.planner:setup(npc) st.properties = {} st.operators = {} -- EVALUATORS -- MANAGER st.properties["end"] = 1 st.properties["locked"] = 2 st.properties["locked_external"] = 3 -- WEAPON st.properties["weapon"] = 11 st.properties["weapon_locked"] = 12 st.properties["weapon_strapped"] = 13 st.properties["weapon_strapped_now"] = 14 st.properties["weapon_unstrapped"] = 15 st.properties["weapon_unstrapped_now"] = 16 st.properties["weapon_none"] = 17 st.properties["weapon_none_now"] = 18 st.properties["weapon_drop"] = 19 st.properties["weapon_fire"] = 20 -- MOVEMENT st.properties["movement"] = 21 st.properties["movement_walk"] = 22 st.properties["movement_run"] = 23 st.properties["movement_stand"] = 24 st.properties["movement_stand_now"] = 25 -- MENTAL STATES st.properties["mental"] = 31 st.properties["mental_free"] = 32 st.properties["mental_free_now"] = 33 st.properties["mental_danger"] = 34 st.properties["mental_danger_now"] = 35 st.properties["mental_panic"] = 36 st.properties["mental_panic_now"] = 37 -- BODYSTATES st.properties["bodystate"] = 41 st.properties["bodystate_crouch"] = 42 st.properties["bodystate_standing"] = 43 st.properties["bodystate_crouch_now"] = 44 st.properties["bodystate_standing_now"] = 45 -- DIRECTION st.properties["direction"] = 51 st.properties["direction_search"] = 52 -- ANIMSTATE st.properties["animstate"] = 61 st.properties["animstate_locked"] = 62 st.properties["animstate_idle_now"] = 64 st.properties["animstate_play_now"] = 66 -- ANIMATION st.properties["animation"] = 81 st.properties["animation_locked"] = 82 st.properties["animation_play_now"] = 84 st.properties["animation_none_now"] = 86 -- SMARTCOVER st.properties["smartcover_need"] = 90 st.properties["smartcover"] = 91 st.properties["in_smartcover"] = 92 -- st.properties["smartcover_locked"] = 92 st.planner:add_evaluator(st.properties["end"], state_mgr.eva_state_mgr_end("state_mgr_end", st)) st.planner:add_evaluator(st.properties["locked"], state_mgr.eva_state_mgr_locked("state_mgr_locked", st)) st.planner:add_evaluator(st.properties["locked_external"], state_mgr.eva_state_mgr_locked_external("state_mgr_locked_external", st)) st.planner:add_evaluator(st.properties["weapon"], state_mgr_weapon.eva_state_mgr_weapon("state_mgr_weapon", st)) st.planner:add_evaluator(st.properties["weapon_locked"], state_mgr_weapon.eva_state_mgr_weapon_locked("state_mgr_weapon_locked", st)) st.planner:add_evaluator(st.properties["weapon_strapped"], state_mgr_weapon.eva_state_mgr_weapon_strapped("state_mgr_weapon_strapped", st)) st.planner:add_evaluator(st.properties["weapon_strapped_now"], state_mgr_weapon.eva_state_mgr_weapon_strapped_now("state_mgr_weapon_strapped_now", st)) st.planner:add_evaluator(st.properties["weapon_unstrapped"], state_mgr_weapon.eva_state_mgr_weapon_unstrapped("state_mgr_weapon_unstrapped", st)) st.planner:add_evaluator(st.properties["weapon_unstrapped_now"], state_mgr_weapon.eva_state_mgr_weapon_unstrapped_now("state_mgr_weapon_unstrapped_now", st)) st.planner:add_evaluator(st.properties["weapon_none"], state_mgr_weapon.eva_state_mgr_weapon_none("state_mgr_weapon_none", st)) st.planner:add_evaluator(st.properties["weapon_none_now"], state_mgr_weapon.eva_state_mgr_weapon_none_now("state_mgr_weapon_none_now", st)) st.planner:add_evaluator(st.properties["weapon_drop"], state_mgr_weapon.eva_state_mgr_weapon_drop("state_mgr_weapon_drop", st)) st.planner:add_evaluator(st.properties["weapon_fire"], state_mgr_weapon.eva_state_mgr_weapon_fire("state_mgr_weapon_fire", st)) st.planner:add_evaluator(st.properties["movement"], state_mgr_movement.eva_state_mgr_movement("state_mgr_movement", st)) st.planner:add_evaluator(st.properties["movement_walk"], state_mgr_movement.eva_state_mgr_movement_walk("state_mgr_movement_walk", st)) st.planner:add_evaluator(st.properties["movement_run"], state_mgr_movement.eva_state_mgr_movement_run("state_mgr_movement_run", st)) st.planner:add_evaluator(st.properties["movement_stand"], state_mgr_movement.eva_state_mgr_movement_stand("state_mgr_movement_stand", st)) st.planner:add_evaluator(st.properties["movement_stand_now"], state_mgr_movement.eva_state_mgr_movement_stand_now("state_mgr_movement_stand_now", st)) st.planner:add_evaluator(st.properties["mental"], state_mgr_mental.eva_state_mgr_mental("state_mgr_mental", st)) st.planner:add_evaluator(st.properties["mental_free"], state_mgr_mental.eva_state_mgr_mental_free("state_mgr_mental_free", st)) st.planner:add_evaluator(st.properties["mental_free_now"], state_mgr_mental.eva_state_mgr_mental_free_now("state_mgr_mental_free_now", st)) st.planner:add_evaluator(st.properties["mental_danger"], state_mgr_mental.eva_state_mgr_mental_danger("state_mgr_mental_danger", st)) st.planner:add_evaluator(st.properties["mental_danger_now"], state_mgr_mental.eva_state_mgr_mental_danger_now("state_mgr_mental_danger_now", st)) st.planner:add_evaluator(st.properties["mental_panic"], state_mgr_mental.eva_state_mgr_mental_panic("state_mgr_mental_panic", st)) st.planner:add_evaluator(st.properties["mental_panic_now"], state_mgr_mental.eva_state_mgr_mental_panic_now("state_mgr_mental_panic_now", st)) st.planner:add_evaluator(st.properties["bodystate"], state_mgr_bodystate.eva_state_mgr_bodystate("state_mgr_bodystate", st)) st.planner:add_evaluator(st.properties["bodystate_crouch"], state_mgr_bodystate.eva_state_mgr_bodystate_crouch("state_mgr_bodystate_crouch", st)) st.planner:add_evaluator(st.properties["bodystate_standing"], state_mgr_bodystate.eva_state_mgr_bodystate_standing("state_mgr_bodystate_standing", st)) st.planner:add_evaluator(st.properties["bodystate_crouch_now"], state_mgr_bodystate.eva_state_mgr_bodystate_crouch_now("state_mgr_bodystate_crouch_now", st)) st.planner:add_evaluator(st.properties["bodystate_standing_now"], state_mgr_bodystate.eva_state_mgr_bodystate_standing_now("state_mgr_bodystate_standing_now", st)) st.planner:add_evaluator(st.properties["direction"], state_mgr_direction.eva_state_mgr_direction("state_mgr_direction", st)) st.planner:add_evaluator(st.properties["direction_search"], state_mgr_direction.eva_state_mgr_direction_search("state_mgr_direction_search", st)) st.animstate = state_mgr_animation.animation(npc, st, "state_mgr_animstate_list") st.planner:add_evaluator(st.properties["animstate"], state_mgr_animstate.eva_state_mgr_animstate("state_mgr_animstate", st)) st.planner:add_evaluator(st.properties["animstate_idle_now"], state_mgr_animstate.eva_state_mgr_animstate_idle_now("state_mgr_animstate_idle_now", st)) st.planner:add_evaluator(st.properties["animstate_play_now"], state_mgr_animstate.eva_state_mgr_animstate_play_now("state_mgr_animstate_play_now", st)) st.planner:add_evaluator(st.properties["animstate_locked"], state_mgr_animstate.eva_state_mgr_animstate_locked("state_mgr_animstate_locked", st)) st.animation = state_mgr_animation.animation(npc, st, "state_mgr_animation_list") st.npc:set_callback(callback.script_animation , st.animation.anim_callback, st.animation) st.planner:add_evaluator(st.properties["animation"], state_mgr_animation.eva_state_mgr_animation("state_mgr_animation", st)) st.planner:add_evaluator(st.properties["animation_play_now"], state_mgr_animation.eva_state_mgr_animation_play_now("state_mgr_animation_play_now", st)) st.planner:add_evaluator(st.properties["animation_none_now"], state_mgr_animation.eva_state_mgr_animation_none_now("state_mgr_animation_none_now", st)) st.planner:add_evaluator(st.properties["animation_locked"], state_mgr_animation.eva_state_mgr_animation_locked("state_mgr_animation_locked", st)) st.planner:add_evaluator(st.properties["smartcover"], state_mgr_smartcover.eva_state_mgr_smartcover("state_mgr_smartcover", st)) st.planner:add_evaluator(st.properties["smartcover_need"], state_mgr_smartcover.eva_state_mgr_smartcover_need("state_mgr_smartcover_need", st)) st.planner:add_evaluator(st.properties["in_smartcover"], state_mgr_smartcover.eva_state_mgr_in_smartcover("state_mgr_in_smartcover", st)) -- st.planner:add_evaluator(st.properties["smartcover_locked"], state_mgr_smartcover.eva_state_mgr_smartcover_locked("state_mgr_smartcover_locked", st)) st.operators["end"] = 1 st.operators["locked"] = 2 st.operators["locked_external"] = 3 st.operators["locked_animation"] = 4 st.operators["locked_animstate"] = 5 st.operators["locked_smartcover"] = 6 st.operators["weapon_strapp"] = 11 st.operators["weapon_unstrapp"] = 12 st.operators["weapon_none"] = 13 st.operators["weapon_fire"] = 14 st.operators["weapon_drop"] = 15 st.operators["movement"] = 21 st.operators["movement_walk"] = 22 st.operators["movement_run"] = 23 st.operators["movement_stand"] = 24 st.operators["movement_walk_turn"] = 25 st.operators["movement_walk_search"] = 26 st.operators["movement_stand_turn"] = 27 st.operators["movement_stand_search"] = 28 st.operators["movement_run_turn"] = 29 st.operators["movement_run_search"] = 30 st.operators["mental_free"] = 31 st.operators["mental_danger"] = 32 st.operators["mental_panic"] = 33 st.operators["bodystate_crouch"] = 41 st.operators["bodystate_standing"] = 42 st.operators["bodystate_crouch_danger"] = 43 st.operators["bodystate_standing_free"] = 44 st.operators["direction_turn"] = 51 st.operators["direction_search"] = 52 st.operators["animstate_start"] = 61 st.operators["animstate_stop"] = 62 st.operators["animation_start"] = 71 st.operators["animation_stop"] = 72 st.operators["walk_turn"] = 75 st.operators["walk_search"] = 76 st.operators["stand_turn"] = 77 st.operators["stand_search"] = 78 st.operators["smartcover_enter"] = 80 st.operators["smartcover_exit"] = 81 --' Actions --************************************************************************************ --* SMART_ACTIONS * --************************************************************************************ -- WEAPON -- UNSTRAPP local action = state_mgr_weapon.act_state_mgr_weapon_unstrapp("state_mgr_weapon_unstrapp", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["weapon_unstrapped"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["weapon"], true)) st.planner:add_action(st.operators["weapon_unstrapp"], action) -- STRAPP action = state_mgr_weapon.act_state_mgr_weapon_strapp("state_mgr_weapon_strapp", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["weapon_strapped"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["weapon"], true)) st.planner:add_action(st.operators["weapon_strapp"], action) -- NONE action = state_mgr_weapon.act_state_mgr_weapon_none("state_mgr_weapon_none", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["weapon_none"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["weapon"], true)) st.planner:add_action(st.operators["weapon_none"], action) -- DROP action = state_mgr_weapon.act_state_mgr_weapon_drop("state_mgr_weapon_drop", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["weapon_drop"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["weapon"], true)) st.planner:add_action(st.operators["weapon_drop"], action) -- MOVEMENT -- WALK action = state_mgr_movement.act_state_mgr_movement_walk("state_mgr_movement_walk", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_walk"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) st.planner:add_action(st.operators["movement_walk"], action) -- WALK_turn action = state_mgr_movement.act_state_mgr_movement_walk_turn("state_mgr_movement_walk_turn", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], false)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_walk"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_walk_turn"], action) -- WALK_search action = state_mgr_movement.act_state_mgr_movement_walk_search("state_mgr_movement_walk_search", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_walk"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_walk_search"], action) -- RUN action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_run"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) st.planner:add_action(st.operators["movement_run"], action) -- RUN_turn action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run_turn", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], false)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_run"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_run_turn"], action) -- RUN_search action = state_mgr_movement.act_state_mgr_movement_run("state_mgr_movement_run_search", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["mental"], true)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement_run"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_run_search"], action) -- STAND action = state_mgr_movement.act_state_mgr_movement_stand("state_mgr_movement_stand", st) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["movement_stand"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_effect (world_property(st.properties["movement"], true)) st.planner:add_action(st.operators["movement_stand"], action) -- STAND_turn action = state_mgr_movement.act_state_mgr_movement_stand_turn("state_mgr_movement_stand_turn", st) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], false)) action:add_precondition (world_property(st.properties["movement_stand"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_stand_turn"], action) -- STAND_search action = state_mgr_movement.act_state_mgr_movement_stand_search("state_mgr_movement_stand_search", st) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["movement"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], true)) action:add_precondition (world_property(st.properties["movement_stand"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_effect (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["movement_stand_search"], action) -- DIRECTION -- TURN action = state_mgr_direction.act_state_mgr_direction_turn("state_mgr_direction_turn", st) --action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], false)) action:add_precondition (world_property(st.properties["weapon"], true))--! action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["direction_turn"], action) -- SEARCH action = state_mgr_direction.act_state_mgr_direction_search("state_mgr_direction_search", st) --action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["direction"], false)) action:add_precondition (world_property(st.properties["direction_search"], true)) action:add_precondition (world_property(st.properties["weapon"], true))--! action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_effect (world_property(st.properties["direction"], true)) st.planner:add_action(st.operators["direction_search"], action) -- MENTAL STATES -- FREE action = state_mgr_mental.act_state_mgr_mental_free("state_mgr_mental_free") action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["mental"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["mental_free"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["bodystate_standing_now"], true)) action:add_effect (world_property(st.properties["mental"], true)) st.planner:add_action(st.operators["mental_free"], action) -- DANGER action = state_mgr_mental.act_state_mgr_mental_danger("state_mgr_mental_danger") action:add_precondition (world_property(st.properties["mental"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["mental_danger"], true)) action:add_effect (world_property(st.properties["mental"], true)) action:add_effect (world_property(st.properties["mental_danger_now"], true)) st.planner:add_action(st.operators["mental_danger"], action) -- PANIC action = state_mgr_mental.act_state_mgr_mental_panic("state_mgr_mental_panic") action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["mental"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["mental_panic"], true)) action:add_effect (world_property(st.properties["mental"], true)) st.planner:add_action(st.operators["mental_panic"], action) -- BODYSTATES -- CROUCH action = state_mgr_bodystate.act_state_mgr_bodystate_crouch("state_mgr_bodystate_crouch") action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["bodystate"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate_crouch_now"], false)) action:add_precondition (world_property(st.properties["bodystate_crouch"], true)) action:add_precondition (world_property(st.properties["mental_danger_now"], true)) action:add_effect (world_property(st.properties["bodystate"], true)) st.planner:add_action(st.operators["bodystate_crouch"], action) -- CROUCH_danger action = state_mgr_bodystate.act_state_mgr_bodystate_crouch_danger("state_mgr_bodystate_crouch_danger") action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["bodystate"], false)) action:add_precondition (world_property(st.properties["mental"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate_crouch_now"], false)) action:add_precondition (world_property(st.properties["bodystate_crouch"], true)) action:add_effect (world_property(st.properties["bodystate"], true)) action:add_effect (world_property(st.properties["mental"], true)) st.planner:add_action(st.operators["bodystate_crouch_danger"], action) -- STAND action = state_mgr_bodystate.act_state_mgr_bodystate_standing("state_mgr_bodystate_standing", st) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["bodystate"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate_standing_now"], false)) action:add_precondition (world_property(st.properties["bodystate_standing"], true)) action:add_effect (world_property(st.properties["bodystate"], true)) action:add_effect (world_property(st.properties["bodystate_standing_now"], true)) st.planner:add_action(st.operators["bodystate_standing"], action) -- STAND_free action = state_mgr_bodystate.act_state_mgr_bodystate_standing_free("state_mgr_bodystate_standing_free", st) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["bodystate"], false)) action:add_precondition (world_property(st.properties["mental"], false)) -- action:add_precondition (world_property(st.properties["weapon"], true)) --' action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["bodystate_standing_now"], false)) action:add_precondition (world_property(st.properties["bodystate_standing"], true)) action:add_precondition (world_property(st.properties["mental_free"], false)) action:add_effect (world_property(st.properties["bodystate"], true)) action:add_effect (world_property(st.properties["bodystate_standing_now"], true)) action:add_effect (world_property(st.properties["mental"], true)) st.planner:add_action(st.operators["bodystate_standing_free"], action) -- ANIMSTATES action = state_mgr_animstate.act_state_mgr_animstate_start("state_mgr_animstate_start", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animstate"], false)) action:add_precondition (world_property(st.properties["smartcover"], true)) action:add_precondition (world_property(st.properties["animation_none_now"], true)) action:add_precondition (world_property(st.properties["direction"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["animstate_play_now"], false)) action:add_effect (world_property(st.properties["animstate"], true)) st.planner:add_action(st.operators["animstate_start"], action) action = state_mgr_animstate.act_state_mgr_animstate_stop("state_mgr_animstate_stop", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animation_locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false))--! --action:add_precondition (world_property(st.properties["animstate"], false)) action:add_precondition (world_property(st.properties["animstate_idle_now"], false)) action:add_precondition (world_property(st.properties["animation_play_now"], false)) action:add_effect (world_property(st.properties["animstate"], true)) action:add_effect (world_property(st.properties["animstate_play_now"], false)) action:add_effect (world_property(st.properties["animstate_idle_now"], true)) st.planner:add_action(st.operators["animstate_stop"], action) -- ANIMATION -- START action = state_mgr_animation.act_state_mgr_animation_start("state_mgr_animation_start", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["animstate_locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) action:add_precondition (world_property(st.properties["animstate"], true)) action:add_precondition (world_property(st.properties["smartcover"], true)) action:add_precondition (world_property(st.properties["in_smartcover"], false)) action:add_precondition (world_property(st.properties["direction"], true)) action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["animation"], false)) action:add_precondition (world_property(st.properties["animation_play_now"], false)) action:add_effect (world_property(st.properties["animation"], true)) st.planner:add_action(st.operators["animation_start"], action) -- STOP action = state_mgr_animation.act_state_mgr_animation_stop("state_mgr_animation_stop", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["locked_external"], false)) --action:add_precondition (world_property(st.properties["animstate"], true)) --action:add_precondition (world_property(st.properties["animation"], false)) action:add_precondition (world_property(st.properties["animation_play_now"], true)) action:add_effect (world_property(st.properties["animation"], true)) action:add_effect (world_property(st.properties["animation_play_now"], false)) action:add_effect (world_property(st.properties["animation_none_now"], true)) st.planner:add_action(st.operators["animation_stop"], action) -- SMARTCOVER - вход action = state_mgr_smartcover.act_state_mgr_smartcover_enter("act_state_mgr_smartcover_enter", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["smartcover_need"], true)) action:add_precondition (world_property(st.properties["smartcover"], false)) action:add_precondition (world_property(st.properties["animstate_idle_now"], true)) action:add_precondition (world_property(st.properties["animation_play_now"], false)) action:add_effect (world_property(st.properties["smartcover"], true)) st.planner:add_action(st.operators["smartcover_enter"], action) -- SMARTCOVER - выход action = state_mgr_smartcover.act_state_mgr_smartcover_exit("act_state_mgr_smartcover_exit", st) action:add_precondition (world_property(st.properties["locked"], false)) action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["smartcover_need"], false)) action:add_precondition (world_property(st.properties["smartcover"], false)) action:add_effect (world_property(st.properties["smartcover"], true)) st.planner:add_action(st.operators["smartcover_exit"], action) action = state_mgr.act_state_mgr_locked("state_mgr_locked_smartcover", st) action:add_precondition (world_property(st.properties["in_smartcover"], true)) action:add_effect (world_property(st.properties["in_smartcover"], false)) st.planner:add_action(st.operators["locked_smartcover"], action) -- LOCKED action = state_mgr.act_state_mgr_locked("state_mgr_locked", st) action:add_precondition (world_property(st.properties["locked"], true)) action:add_effect (world_property(st.properties["locked"],false)) st.planner:add_action(st.operators["locked"], action) action = state_mgr.act_state_mgr_locked("state_mgr_locked_animation", st) action:add_precondition (world_property(st.properties["animation_locked"], true)) action:add_effect (world_property(st.properties["animation_locked"],false)) st.planner:add_action(st.operators["locked_animation"], action) action = state_mgr.act_state_mgr_locked("state_mgr_locked_animstate", st) action:add_precondition (world_property(st.properties["animstate_locked"], true)) action:add_effect (world_property(st.properties["animstate_locked"],false)) st.planner:add_action(st.operators["locked_animstate"], action) action = state_mgr.act_state_mgr_locked("state_mgr_locked_external", st) action:add_precondition (world_property(st.properties["locked_external"], true)) action:add_effect (world_property(st.properties["locked_external"],false)) st.planner:add_action(st.operators["locked_external"], action) -- END action = state_mgr.act_state_mgr_end("state_mgr_end", st) action:add_precondition (world_property(st.properties["end"], false)) action:add_precondition (world_property(st.properties["weapon"], true)) action:add_precondition (world_property(st.properties["movement"], true)) action:add_precondition (world_property(st.properties["mental"], true)) action:add_precondition (world_property(st.properties["bodystate"], true)) action:add_precondition (world_property(st.properties["direction"], true)) action:add_precondition (world_property(st.properties["animstate"], true)) action:add_precondition (world_property(st.properties["animation"], true)) action:add_precondition (world_property(st.properties["smartcover"], true)) action:add_effect (world_property(st.properties["end"], true)) st.planner:add_action(st.operators["end"], action) local goal = world_state() goal:add_property(world_property(st.properties["end"],true)) st.planner:set_goal_world_state(goal) if npc.debug_planner ~= nil then npc:debug_planner(st.planner) end end