function printf() end --' ПЕРЕМЕЩЕНИЕ --' мы уже находимся в необходимом состоянии? class "eva_state_mgr_movement" (property_evaluator) function eva_state_mgr_movement:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_movement:evaluate() -- printf("MOVE: %s",utils.to_str((state_lib.states[self.st.target_state].movement == nil) or -- (state_lib.states[self.st.target_state].movement == self.object:target_movement_type()))) -- printf("MOVE: %s",utils.to_str(self.object:target_movement_type())) return (state_lib.states[self.st.target_state].movement == nil) or (state_lib.states[self.st.target_state].movement == self.object:target_movement_type()) -- (state_lib.states[self.st.target_state].movement == self.object:movement_type()) end --' нужно ли нам идти class "eva_state_mgr_movement_walk" (property_evaluator) function eva_state_mgr_movement_walk:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_movement_walk:evaluate() return state_lib.states[self.st.target_state].movement == move.walk end --' нужно ли нам бежать class "eva_state_mgr_movement_run" (property_evaluator) function eva_state_mgr_movement_run:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_movement_run:evaluate() return state_lib.states[self.st.target_state].movement == move.run end --' нужно ли нам стоять class "eva_state_mgr_movement_stand" (property_evaluator) function eva_state_mgr_movement_stand:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_movement_stand:evaluate() return state_lib.states[self.st.target_state].movement == move.stand end --' стоим ли мы class "eva_state_mgr_movement_stand_now" (property_evaluator) function eva_state_mgr_movement_stand_now:__init(name, st) super (nil, name) self.st = st end function eva_state_mgr_movement_stand_now:evaluate() return self.object:target_movement_type() == move.stand -- return self.object:movement_type() == move.stand end --' Включаем ходьбу class "act_state_mgr_movement_walk" (action_base) function act_state_mgr_movement_walk:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_walk:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) self.object:set_movement_type(move.walk) --printf("ENABLING MOVEMENT ") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) end function act_state_mgr_movement_walk:execute() action_base.execute(self) end function act_state_mgr_movement_walk:finalize() action_base.finalize(self) end --' Включаем бег class "act_state_mgr_movement_run" (action_base) function act_state_mgr_movement_run:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_run:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) self.object:set_movement_type(move.run) -- printf("ENABLING MOVEMENT !!!!!") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) end function act_state_mgr_movement_run:execute() action_base.execute(self) end function act_state_mgr_movement_run:finalize() action_base.finalize(self) end --' Включаем стояние на месте class "act_state_mgr_movement_stand" (action_base) function act_state_mgr_movement_stand:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_stand:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- stand", tostring(self.object:movement_type())) self.object:set_movement_type(move.stand) end function act_state_mgr_movement_stand:execute() action_base.execute(self) end function act_state_mgr_movement_stand:finalize() action_base.finalize(self) end --'********************************************************************* --'* smart actions * --'********************************************************************* --' STAND_turn class "act_state_mgr_movement_stand_turn" (action_base) function act_state_mgr_movement_stand_turn:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_stand_turn:initialize() action_base.initialize(self) state_mgr_direction.turn(self.object, self.st) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- stand", tostring(self.object:movement_type())) self.object:set_movement_type(move.stand) end function act_state_mgr_movement_stand_turn:execute() action_base.execute(self) end function act_state_mgr_movement_stand_turn:finalize() action_base.finalize(self) end --' STAND_search class "act_state_mgr_movement_stand_search" (action_base) function act_state_mgr_movement_stand_search:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_stand_search:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- stand", tostring(self.object:movement_type())) self.object:set_movement_type(move.stand) printf("SET_SIGHT!!!act_state_mgr_movement_stand_search:initialize()") self.object:set_sight(state_mgr_direction.look_position_type(self.object, self.st), nil, 0) end function act_state_mgr_movement_stand_search:execute() action_base.execute(self) end function act_state_mgr_movement_stand_search:finalize() action_base.finalize(self) end --' WALK_turn class "act_state_mgr_movement_walk_turn" (action_base) function act_state_mgr_movement_walk_turn:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_walk_turn:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) self.object:set_movement_type(move.walk) -- printf("ENABLING MOVEMENT !!!!!") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) state_mgr_direction.turn(self.object, self.st) end function act_state_mgr_movement_walk_turn:execute() action_base.execute(self) end function act_state_mgr_movement_walk_turn:finalize() action_base.finalize(self) end --' WALK_search class "act_state_mgr_movement_walk_search" (action_base) function act_state_mgr_movement_walk_search:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_walk_search:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) self.object:set_movement_type(move.walk) -- printf("ENABLING MOVEMENT !!!!!") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- WALK", tostring(self.object:movement_type())) printf("SET_SIGHT!!!act_state_mgr_movement_walk_search:initialize()") self.object:set_sight(state_mgr_direction.look_position_type(self.object, self.st), nil, 0) end function act_state_mgr_movement_walk_search:execute() action_base.execute(self) end function act_state_mgr_movement_walk_search:finalize() action_base.finalize(self) end --' RUN_turn class "act_state_mgr_movement_run_turn" (action_base) function act_state_mgr_movement_run_turn:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_run_turn:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) self.object:set_movement_type(move.run) -- printf("ENABLING MOVEMENT !!!!!") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) state_mgr_direction.turn(self.object, self.st) end function act_state_mgr_movement_run_turn:execute() action_base.execute(self) end function act_state_mgr_movement_run_turn:finalize() action_base.finalize(self) end --' RUN_search class "act_state_mgr_movement_run_search" (action_base) function act_state_mgr_movement_run_search:__init(name, st) super (nil, name) self.st = st end function act_state_mgr_movement_run_search:initialize() action_base.initialize(self) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) self.object:set_movement_type(move.run) -- printf("ENABLING MOVEMENT !!!!!") --'self.object:movement_enabled(true) --printf("MOVEMENT TYPE IS --- %s setting MOVEMENT TYPE --- RUN", tostring(self.object:movement_type())) printf("SET_SIGHT!!!act_state_mgr_movement_run_search:initialize()") self.object:set_sight(state_mgr_direction.look_position_type(self.object, self.st), nil, 0) end function act_state_mgr_movement_run_search:execute() action_base.execute(self) end function act_state_mgr_movement_run_search:finalize() action_base.finalize(self) end