Jump to content
Sign in to follow this  
marki980908

Civilian interaction (add action)

Recommended Posts

I have this code from another old ARMA 3 topic.
 

Spoiler

action_interrogate = player addAction["Interrogate", { 
    0 = cursorTarget spawn interrogate
}, nil, 1.5, false, true, "", " 
    (alive cursorTarget && side cursorTarget == civilian && {player distance cursorTarget < 3})
"];

directionText = {
    if ((_this > 22.5) && (_this <= 67.5)) exitWith {"NORTHEAST"};
    if ((_this > 67.5) && (_this <= 112.5)) exitWith {"EAST"};
    if ((_this > 112.5) && (_this <= 157.5)) exitWith {"SOUTHEAST"};
    if ((_this > 157.5) && (_this <= 202.5)) exitWith {"SOUTH"};
    if ((_this > 202.5) && (_this <= 247.5)) exitWith {"SOUTHWEST"};
    if ((_this > 247.5) && (_this <= 295.5)) exitWith {"WEST"};
    if ((_this > 295.5) && (_this <= 337.5)) exitWith {"NORTHWEST"};
    "NORTH"
};

interrogate = {
    if (random 100 > 5) exitWith {systemChat "I don't feel like talking..."};

    private "_enemy";
    _enemy = { if (side _x == east || side _x == independent) exitWith {_x}; objNull } forEach (_this nearEntities [["Man", "Air", "Car", "Motorcycle", "Tank"],1000] - [player]);
    if (isNull _enemy) exitWith {systemChat "I've seen no baddies recently"};

    systemChat format["There is a %1 group of enemies to the %2 of here",
        call {
            private "_n";
            _n = count units group _enemy;
            switch true do {
                case (_n > 8): {"massive"};
                case (_n > 5): {"large"};
                case (_n > 0): {"small"};
                default "";
            }
        },
        ([_this,_enemy] call BIS_fnc_dirTo) call directionText
    ];
};

It is well and all, but what I am looking for simply is: you addaction "interact" to a civilian, and than civilian will randomly reply with one of the few prewritten lines.
I tried to change code above to something like this:
 

Spoiler

action_interrogate = player addAction["Interact", { 
    0 = cursorTarget spawn interrogate
}, nil, 1.5, false, true, "", " 
    (alive cursorTarget && side cursorTarget == civilian && {player distance cursorTarget < 3})
"];

interact = {
    if (random 100 > 5) exitWith {systemChat "I don't feel like talking..."};

But it doesnt seem to work, also I would like this code to apply only to unit in whos init box I put the code in, not to all civilians.
And I would like to be able to pre-write like 20 different lines AI could say
Can anyone help?

EDIT: Long story short I need a script, which would work like this: you approach curtain AI, scroll wheel, select "interact", and it will reply to you in chat with 1 out of X number of prewritten responses.

EDIT: Found the answer!
 

Spoiler

this addAction ["Interact", {systemChat (selectRandom 
[ "Hello", "fuck off", "good day", "blabla" ])}, 
nil, 1.5, true, true, "", "alive _originalTarget", 4, false, "", ""];

 

Share this post


Link to post
Share on other sites

Please sign in to comment

You will be able to leave a comment after signing in



Sign In Now
Sign in to follow this  

×