Jump to content

No AI Damage to Players


axeman

Recommended Posts

Enabled.

I run my test server with the default settings.

The problem is, in the file "\compile\epoch_player\EPOCH_server_loadPlayer.sqf" located in the "a3_epoch_server.pbo" where the Server sets "allowDamage" to "false" on the player object (but only does this for the first time the client spawns in).

For anyone interested in how to "fix" this:

A simple fix for this is, to wait until the player object returns the variable "SETUP" with true (because this happens after allowDamage is set to false) and then simply use "allowDamage true" on the player object.

After that, everything works fine, AI spawned by the Server can kill the player and so far I have not seen any EPOCH vanilla script or function being broken or showing unwanted behaviour after adding this "fix" to my AI Mission System (currently not released version).

So may I ask You a question back:

Why do You even need to have this line "_av allowDamage false;" in the Script and could You change "allowDamage" back to "true" after whatever You needed to set this command to "false" in the first place?

Another question (not relatet to this topic directly) is in the spoiler:

In the file

You have this line of Code

onPlayerConnected{"EpochServer" callExtension format["001|%1",_uid]};
Could You please use the A3 function "BIS_fnc_addStackedEventHandler" instead, so addon creators do not need to do ugly workarounds like waiting until a global variable after this line is defined in Your code to add their stackedEH for "onPlayerConnected".

If You need an example, here You have one:

waitUntil{!isNil "epoch_centerMarkerPosition"};

["KS_Random_id", "onPlayerConnected", "KS_fnc_allowPlayerDamage"] call BIS_fnc_addStackedEventHandler;
If I don't wait until the variable "epoch_centerMarkerPosition" gets defined, my stacked EH for "onPlayerConnected" simply gets overwritten by the "blank" use of "onPlayerConnected" in Your code.

For now, the method I'm showing you here does work, but what if You change the Name of the Variable or decide to define this variable before adding Your "onPlayerConnected" eventHandler?

Please use "BIS_fnc_addStackedEventHandler" when ever possible, it was added by BIS exactly for such compatibility reasons.

Sorry for my bad writing, but I'm in a hurry, will later have more time if You have some questions or want to discuss some details.

Greez KiloSwiss

Link to comment
Share on other sites

Also been testing with missions and have not run into the issue yet, have seen that setting and where it is enabled again.

 

KiloSwiss, to answer your question, I don't know the exact answer, I am just getting back into the sqf to continue with the mission system I started on a while back, but from experience with A2, spawning a player in and applying the persistence is not altogether straight forward, especially when dealing with players logging / losing connection / deliberately disconnecting. I suspect it will be to do with transfer from 'debug' to real in-game life.

 

Is also a question myself and Skaronator are looking at..

Edit: And Skaro has a fix :)

Link to comment
Share on other sites

Kilo I think their intent is to prevent players from somehow taking damage in the spawn building (cloning facility). It's possible that a scripter could find their way into the building and massacre freshies. Using setdamage to false on first spawn would fix that. But if they would change it to setdamage true after a player teleports out of it then the problem would be solved.

Link to comment
Share on other sites

The "allowDamage false" has been an infuriating issue to fix due to the problems it causes to AI addons. It only prevents damage caused by server sources (ie: AI spawned by server) but not damage caused by players. There isn't any server-spawned AI in vanilla Epoch so it's strange why allowDamage is needed. If it's to prevent damage to the player unit between the time it's created on the server and transferred to the player's control, then "allowDamage true" needs to be invoked on the player unit once the transfer is complete.

 

At the moment I'm using a constant server-side loop to apply a one-time "allowDamage true" to each connecting player to allow server-sourced damage but this not an optimal solution. Using a stacked onPlayerConnected eventhandler to apply "allowDamage true" once to each connecting player could have been an easy workaround but Epoch's use of the old non-stacked onPlayerConnected EH prevents this.

Link to comment
Share on other sites

This is my current workaround for the allowDamage issue. It's a simpler and more efficient solution in my opinion and uses only a single playableUnits loop - remember, if you have 50 players online, using "count playableUnits"  will iterate through 50 different objects.

if (!isNil "A3EAI_allowDamageFix_active") exitWith {};
A3EAI_allowDamageFix_active = true;

uiSleep 5;

while {true} do {
    private ["_playersModified"];
    _playersModified = {
        if ((_x getVariable ["noDamageAllowed",true]) && {!(_x isKindOf "VirtualMan_EPOCH")}) then {
            if (isPlayer _x) then {
                _x allowDamage true;
                _x setVariable ["noDamageAllowed",false];
                true
            };
        };
    } count playableUnits;
    if (_playersModified > 0) then {diag_log format ["DEBUG :: Applied allowDamage:true to %1 players.",_playersModified]};
    uiSleep 10;
};

If anyone wishes to use the script as-is, try to keep the "A3EAI_allowDamageFix_active" variable unchanged so that there aren't multiple copies of this loop running if multiple people wish to use this code in their own scripts.

Link to comment
Share on other sites

@axeman: I've always wondered, what is the actual purpose of the allowDamage false setting then, if you're aware of it? I'm not sure what type of server-side damage is expected that would make this necessary, other than preventing fall damage during creation of the player unit, before locality is transferred to the player client.

Link to comment
Share on other sites

The idea was to block any damage during player creation. I also have a feeling we added it in during the hacker frenzy, we were on the servers at the time fighting against them as best we could, is mostly how we discovered the vulnerability reported and was subsequently fixed by BIS.

 

I expect it may stay in, it will just be handled differently during player creation.

Link to comment
Share on other sites

Thanks for the insights so far axeman, your appearance here in this forum is well appreciated.

 

Do You (the dev. team) plan to use "BIS_fnc_addStackedEventHandler" in the future to allow better compatibility with user mods?

I'm talking especially about the current (not so smart) use of "onPlayerconnected" in the EPOCH MOD server files.

 

Greez KiloSwiss

Link to comment
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
  • Advertisement
  • Discord

×
×
  • Create New...