16 августа 2013 г.

Принятие решений

Разберём Decision maker
Теперь актёр может принимать какие-либо решения в зависимости от ситуации. В данном случае актёр по-разному реагирует на прицеливание: он может как пригнуться, защищая себя, так и начать атаковать. Но при получении повреждений от кого-нибудь он сразу атакует.

// $PLAYER_ACTOR $PLAYER_GROUP $ONMISSION
{$CLEO}
0000:
while true //1
wait 0
    if //2
    player.Defined(0)
    then
        if and //3
        not actor.Dead($PLAYER_ACTOR)
        not actor.Driving($PLAYER_ACTOR)
        0ADC:   test_cheat "DECIS"
        then
        model.Load(#MP5LNG)
        038B: load_requested_models
        04C4: store_coords_to 0@ 1@ 2@ from_actor $PLAYER_ACTOR with_offset 0.0 3.0 0.0
        actor.Create(3@,Special,#MALE01,0@,1@,-100.0) // #MALE01 #NULL
        actor.GiveWeaponAndAmmo(3@,MP5,-1)
        087E: set_actor 3@ weapon_droppable 0
        model.Destroy(#MP5LNG)
        060A: create_decision_maker_type 0 store_to 4@
        077A: set_actor 3@ acquaintance 3 to_actors_pedtype 0 // see ped.dat
        0709: set_decision_maker 4@ on_event 31 task 1000 respect 0.0 hate 50.0 like 0.0 dislike 20.0 in_car 0 on_foot 1
        0709: set_decision_maker 4@ on_event 31 task 415 respect 0.0 hate 50.0 like 0.0 dislike 80.0 in_car 0 on_foot 1
        0709: set_decision_maker 4@ on_event 9 task 1000 respect 0.0 hate 100.0 like 0.0 dislike 100.0 in_car 1 on_foot 1      
        060B: set_actor 3@ decision_maker_to 4@
        marker.CreateAboveActor(5@,3@)
            repeat
            wait 0
                if
                8104: not  actor $PLAYER_ACTOR near_actor 3@ radius 30.0 30.0 30.0 sphere 0
                then
                break
                end
            until actor.Dead(3@)
        marker.Disable(5@)
        065C: release_decision_maker 4@
        actor.RemoveReferences(3@)
        end //3
    end //2
end //1


Комментариев нет: