How to realese message when agent/bot (ai) kill player?

now work with dzms and dzmsHotSpots, but don't know how to create in wai, so many scripts and variables giving humanity i think this on_kill in 52-59 line in exitWith block
 
wai now work, but have problem when bot killed in systemchat i see [BOT] e-2-t (not bot name) but if hi kill me i see his name in plant down (cutText), where my problem?

all fixed

new problem how set name bot setName command don't work
 
Last edited:
i try with wai bots, add to wai static mission 10 parametr (10 parametr in array to call spawn_group)
Code:
"test bot"
and in script spawn group
Code:
add private _bot_name
this 9 = _bot_name
after create unit
Code:
if !isNil _bot_name
_unit setName _bot_name
but name don't changed..

maybe try to setIdentity command?

setIdentity command change name only in give money action, when bot kill me or i kill him, i see him real name (not setIdentity), this not work:
Code:
_unit = cursorTarget;
_unit setVariable ["bodyName","Mayor George",true];

i read in biwiki setName command work with player only in arma 3
 
Last edited:
add private _bot_name
this 9 = _bot_name

shouldnt that be?
_bot_name = this select 9

the arm3,setname,means it will only work with players when,using arma3. it,works,as,described in arma2
 
i now created EH for setIdentity and all works :) this command local and reset bodyName variable

now try create image for static weapons (killing messages)
added StaticWeapon to array in fnc_plyrHit don't work..
 
i think i know where problem (when player killing me is m2(m2 - weapon (gun) in vehicle m2)) but script try found image in cfgWeapons m2, but me need m2 CfgVehicles image for m2 cfgWeapons

no-no, problem in if
if ((getText (configFile >> "CfgVehicles" >> _vehicle >> "vehicleClass")) in Array
but... i add to this array StaticWeapon
 
Last edited:
i created fix for static weapons (for killing messages), need last thing, message when zombie killing player, i think i need edit player_zimbieAttack or zombie fsm... who have ideas for create this?
 
Last edited:
don't understand where my problem in damage EH i add this:
Code:
if (_ammo == "zombie") then {
    player setVariable ["udarenZombie", true, true];
    diag_log "setVariable udarenZombie true";
};
when zombie attack me i see in log ths message (setVariable udarenZombie true), in server_playerDied i add
Code:
private ["_udarenZombie"];
_udarenZombie = _victim getVariable["udarenZombie", false];
diag_log "_udarenZombie";
diag_log _udarenZombie;
in log i see true
Code:
if (_udarenZombie) then {
    _loc_message = format["PLAYERDEADOTZOMBIE: %1 eaten by zombies", _victimName];
    _message = format ["%1 eaten by zombies",_victimName];
};
and change suicide if to:
Code:
if (((owner _victim) == (owner _killer)) && (!_udarenZombie)) then {
but don't see message\log message if i killed by zombies, where my problem (suicide and when i kulled bots all works)?
 
Last edited:
Great thread. I looked into adding hit & killed messages from AI (and to AI etc..) and I notice that by default (talking vanilla 1.7.6.1 mod Im using), AI & zombie killers are nil in server_playerDied. On the server side when player logs in the 'MPHit' MPeventhander gets added to the server side player object (still trying to understand the nuances here). Its sounds like the secret to getting AI & zombie killers/hitters to to register in server_playerDied.sqf is by adding the MPHit & MPKilled MPEventHandlers on the 'player' client side in the init.sqf and player_spawn_2.sqf ? Is that what you meant by player_spawn?
It would be cool to add the same event handlers to the bloodsuckers and AI, to notify that they were bagged by others. Zombies might be too much bandwidth?
 
i now created for
Code:
bots
zombies
dogs
bloodckers
fix icon for static guns
dead messages for bot dead in systemchat
[BOT] prefix
bot names (Mayor George, KRK Guard, Sector B Guard, CDC Scientist)
no i add var when zombie hit me
 
Last edited:
Nuances:
Server there is NO player object.


I really gave up reading hekuts code, snippets are hard to understand and he got it all worked out. So not really sure what his solution was. Here is MY solution:
When an ai is created add a variable to it to let you know its an AI. In this case, he wanted a name. So in DZAI there is a file fn_spawngroup. It ALREADY ADDS THE NAME to the units variables as "bodyName"
Code:
private ["_type","_unit"];
    _type = DZAI_BanditTypes call BIS_fnc_selectRandom2;                                // Select skin of AI unit
    _unit = _unitGroup createUnit [_type, _pos, [], 0, "FORM"];                            // Spawn the AI unit
    _unit setPos _pos;
    [_unit] joinSilent _unitGroup;                                                        // Add AI unit to group

    _unit setVariable ["bodyName",(name _unit)];                                        // Set unit body name (will be PVed upon death).
    _unit setVariable ["unithealth",[(DZAI_baseBlood + (random DZAI_bonusBlood)),0,false]];                    // Set unit health (blood, legs health, legs broken)
    _unit setVariable ["unconscious",false];                                            // Set unit consciousness
    _unit addEventHandler [DZAI_healthType, DZAI_healthStatements];
    0 = [_unit, _weapongrade] call DZAI_setupLoadout;                                    // Assign unit loadout
    0 = [_unit, _weapongrade] call DZAI_setSkills;                                        // Set AI skill
    if (DZAI_weaponNoise) then {_unit addEventHandler ["Fired", {_this call DZAI_aiFired;}];}; // Unit firing causes zombie aggro in the area, like player.
    if (DZAI_debugLevel > 1) then {diag_log format["DZAI Extended Debug: Spawned AI Type %1 with weapongrade %2 for group %3 (fnc_createGroup).",_type,_weapongrade,_unitGroup];};
};

So now you add an MPKILLED eventhandler to your player. This passes the KILLER object to your script. So all you have to do is this:

  • if (_killer getvariable["bodyname",""]) then {
    //player killed by DZAI
  • Add same setvariable code as DZAI has into WAI or the Missions when each unit is created.
  • add another check to see if _killer is a player and then user playername. its already in epoch.
  • in player_handledamage.sqf add a publicvariable "killedbyzombie" and broadcast that. In the MPKILLED script, we check if that variable is true.
So now we know if player was killed by another player,AI, zombie very easily.
 
thanks shootingblanks. Ah, I see in damager handler, I will be able to get the source there locally, bloodsucker, bandit, zombie, and add a publiceventhandler to 'killedbyzombie' or 'attackedbyzombie' or whatever I call it.
Hmmn, could make it a local setvariable , and then on player_death.sqf, broadcast there from client to server with a public var.

As far as ai killing ai, or zeds, can add local event killed event handlers on them, and have that do an rspawn for systemchat or globalchat call in there.

Interesting that DZAI setvariables are false, not true, so they remain on the server, where the AI is created, which gets to my own particular issue:

By default, I cannot even access _killer, returns "nil" for AI (much like zeds) in server_playerDied.sqf (though halo jumping into trees registered hits!). Its set by the 'AttackedBy' variable in a similar function to fnc_plyrHit.sqf (called server_playerHit.sqf), which again is all server side. So a getvariable on _killer may not work in my case?

The 'player' object is only local to the client is what you are saying? which I understand that much. When a player/client logs in, a copy of the 'player' object gets sent to the server and in server_playerSetup.sqf its called _playerObj, and the MPHit eventhandler gets added there on the server, as well as a bunch of public variables, which must get replicated to proper 'player' object on the client? :confused:

So I was trying to get to the point where I could at least have my MPKilled/server_playerDied.sqf not return "nil" for AttackedBy variable.

But your response helps a lot and given me some ideas. my fnc_plyrHit.sqf, sets AttackedBy as public etc... (like other versions) which is referenced by server_playerdied, so recording locally via damage handler of who hit me last, I can probably set AttackedBy in player_death.sqf as well, for the server to read in server_playerdied.sqf.
And in that function call, finally access the AI "bodyName" variables on the server locally for the name of the AI.

This is a sort of data dump, as I've been staring at code for the last week on my mod, and Im brainstorming. :) Let me know if I am misunderstanding anything.
 
Use damage EH for set player var if him hit zombies and get this var in server_playerDead and translate message to all clients
 
OK, thanks. my version of 'fnc_plyrHit.sqf' is set on 'server_Playersetup.sqf' on _playerObj on server side.

By damage EH, you mean 'MPHit', or player_handledamage.sqf ? If MPHit, is it set on the client side code? i.e. on the 'player' object. I presume so.
 
hekut knows what he is doing. But it gives me a headache to read the incomplete comments. its hard enough with the language, needs to go more in depth to make sure his point is understood.

Thats odd that ai still return _killer nill object. I am sure its not needing all those other EH since its always printed to the logs. The data is available. But I guess what he is saying is that the killer is not sent to the MPKILLED eventhander if its an ai or zombie but it is sent to the MPHIT eventhandler. So he saves the last entity to hit you and uses that for the mpkilled data ... I guess thats what he means.

As for the player object on the server. When you login and request authentication, the server gets your data from the database, creates the player object and then passes that to the client. Thats why there is no player object on the server, there is no actual player.
 
player_handledamage.sqf add to down
if (_ammo == "zombie") then {
player setVariable ["udarenZombie", true, true];
} else {
player setVariable ["udarenZombie", false, true];
};
and edit server_playerDead to get this var and translate message
 
Last edited:
Back
Top