Is it possible to change the humanity gained or lossed from player kills?

DangerRuss

OpenDayZ Rockstar!
Curious if this is possible. Id like to make it so players gained a ltitle humanity from killing bandits. Ive looked in a few places in my server files and in my client side dayz code but Im not seeing anything.
 
Yes it is, take a look at player_death.sqf that's where its done, the player dying is the one who changes their killers humanity "_source" is the unit who killed them
 
Yes it is, take a look at player_death.sqf that's where its done, the player dying is the one who changes their killers humanity "_source" is the unit who killed them

Could you please lend me a hand? Am I looking at this block of code in the player_death.sqf?
Code:
_array = _this;
if (count _array > 0) then {
    _source = _array select 0;
    _method = _array select 1;
    if ((!isNull _source) and (_source != player)) then {
        _canHitFree = player getVariable ["freeTarget",false];
        _isBandit = (player getVariable["humanity",0]) <= -2000;
        _punishment = _canHitFree or _isBandit; //if u are bandit or start first - player will not recieve humanity drop
        _humanityHit = 0;
        if (!_punishment) then {
            //i'm "not guilty" - kill me and be punished
            _myKills = ((player getVariable ["humanKills",0]) / 30) * 1000;
            _humanityHit = -(2000 - _myKills);
            _kills = _source getVariable ["humanKills",0];
            _source setVariable ["humanKills",(_kills + 1),true];
            PVDZ_send = [_source,"Humanity",[_source,_humanityHit,300]];
            publicVariableServer "PVDZ_send";
        } else {
            //i'm "guilty" - kill me as bandit
            _killsV = _source getVariable ["banditKills",0];
            _source setVariable ["banditKills",(_killsV + 1),true];
        };

How would I edit this so killing a bandit would increase humanity? I can see where it determines if you are a bandit humanity <= -2000, and I can see there is no punishment for killing a bandit.. but how could I change the actual humanity gained or lost. Also, what exactly is canHitFree and "freeTarget?" Thanks for any help in advance my friend.
 
Could you please lend me a hand? Am I looking at this block of code in the player_death.sqf?
Code:
_array = _this;
if (count _array > 0) then {
    _source = _array select 0;
    _method = _array select 1;
    if ((!isNull _source) and (_source != player)) then {
        _canHitFree = player getVariable ["freeTarget",false];
        _isBandit = (player getVariable["humanity",0]) <= -2000;
        _punishment = _canHitFree or _isBandit; //if u are bandit or start first - player will not recieve humanity drop
        _humanityHit = 0;
        if (!_punishment) then {
            //i'm "not guilty" - kill me and be punished
            _myKills = ((player getVariable ["humanKills",0]) / 30) * 1000;
            _humanityHit = -(2000 - _myKills);
            _kills = _source getVariable ["humanKills",0];
            _source setVariable ["humanKills",(_kills + 1),true];
            PVDZ_send = [_source,"Humanity",[_source,_humanityHit,300]];
            publicVariableServer "PVDZ_send";
        } else {
            //i'm "guilty" - kill me as bandit
            _killsV = _source getVariable ["banditKills",0];
            _source setVariable ["banditKills",(_killsV + 1),true];
        };

How would I edit this so killing a bandit would increase humanity? I can see where it determines if you are a bandit humanity <= -2000, and I can see there is no punishment for killing a bandit.. but how could I change the actual humanity gained or lost. Also, what exactly is canHitFree and "freeTarget?" Thanks for any help in advance my friend.

_humanityHit is the amount of humanity lost from a kill. isBandit is checking if the player dying had less than or equal -2k humanity.
_canhitFree is based off the freeTarget variable which I think was something that was meant to be set to true if you shoot first in a fight, you can ignore it in your own implementation.
_punishment is set to true if the player dying was a bandit or if _canHitFree is true.

So currently killing a bandit will return _isBandit = true, which in turn will mean _punishment is true, which means the block of code that lowers your humanity will not run

Code:
            _myKills = ((player getVariable ["humanKills",0]) / 30) * 1000;
            _humanityHit = -(2000 - _myKills);
            _kills = _source getVariable ["humanKills",0];
            _source setVariable ["humanKills",(_kills + 1),true];
            PVDZ_send = [_source,"Humanity",[_source,_humanityHit,300]];
            publicVariableServer "PVDZ_send";

You need to determine both killer and victim humanity for your solution

Code:
            if ((player getVariable["humanity",0]) <= -2000) then {
                _victimisBandit = true;
            }
            else {
                if ((player getVariable["humanity",0]) >= 5000) then {
                    _victimisHero = true;
                }
                else {
                    _victimisSurvivor = true;
                };
            };
           
            if ((_source getVariable["humanity",0]) <= -2000) then {
                _killerisBandit = true;
            }
            else {
                if ((_source getVariable["humanity",0]) >= 5000) then {
                    _killerisHero = true;
                }
                else {
                    _killerisSurvivor= true;
                };
            };

A test like that should give you all the information you need to then apply your humanity hit later on.
 
what about a code that determines if a civilian or hero (nonbandit) fires on another nonbandit, is there a way to add a code that checks self defense thus wont withdraw humanity from the self defending player?

scenario:
2 guys stumble up on eachothers, none bandits, civilian 1 fires on civilian 2. Civilian 2 responds the fire and kills civilian 1 and gets 0 or + humanity instead of - humanity.
 
Back
Top