[RELEASE] DayZ Origins-like DiscoBot

ScareD

New Member
Version: 1.1
WORKING AND TESTED WITH 1.8.0.3

What it is?
This script spawns a bot on each player disconnect. Bot could be hurt by other players or vehicles, but cannot interract with zombies and environment. It's the DayZ Origins bot, just ported to any other DayZ mod (I added connection timer, so player won't connect to the server while his bot is alive).​

Requirements
*Notepad++
*Unpacked server and client .pbos
*PBO Editor in case you want to use this in your dayz_server.pbo (other way is mission file)

Difficulty
Easy,tooks 5-10 minutes of code editing

All the installation steps are two-typed: (A) for those who edit dayz_server.pbo and (B) for those who don't want to edit dayz_server.pbo and just wants to edit mission file.

Installation Steps
1) Download The following archive:
https://mega.co.nz/#!M5gyRY7I!LdeiBgTrSuyeTORxYDfRFFfqhbZxdN-m2TRcDn4Box8

Unpack it into
(A)
Your dayz_server pbo-pack folder, if you use edited dayz_server.pbo (or right into the dayz_server.pbo)
(B)
Your mission folder if you want to use mission-edit style

2) Open your server_functions.sqf file and under the following line
Code:
server_plantSpawner =        compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\server_plantSpawner.sqf";

ADD:
(A)
Code:
disco_playerMorph =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\disco_playerMorph.sqf";
disco_damageHandler =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\disco_damageHandler.sqf";
disco_playerDeath  =    compile preprocessFileLineNumbers "\z\addons\dayz_server\compile\disco_playerDeath.sqf";
botPlayers = [];
(B)
Code:
disco_playerMorph =    compile preprocessFileLineNumbers "disco_playerMorph.sqf";
disco_damageHandler =    compile preprocessFileLineNumbers "disco_damageHandler.sqf";
disco_playerDeath  =    compile preprocessFileLineNumbers "disco_playerDeath.sqf";
botPlayers = [];

3) At the server_functions.sqf find the following line (for both (A) and (B)):
Code:
server_hiveWrite = {
And before this line add:
Code:
server_characterSync = {
private ["_characterID","_playerPos","_playerGear","_playerBackp","_medical","_currentState","_currentModel","_key"];
_characterID =  _this select 0;
_playerPos = _this select 1;
_playerGear = _this select 2;
_playerBackp = _this select 3;
_medical =  _this select 4;
_currentState = _this select 5;
_currentModel = _this select 6;
_key = format["CHILD:201:%1:%2:%3:%4:%5:%6:%7:%8:%9:%10:%11:%12:%13:%14:%15:%16:",_characterID,_playerPos,_playerGear,_playerBackp,_medical,false,false,0,0,0,0,_currentState,0,0,_currentModel,0];
_key call server_hiveWrite;
};

4) Open your server_onPlayerDisconnect.sqf (for both (A) and (B))
Replace the following code:
Code:
if (alive _playerObj) then {
  [_playerObj,nil,true] call server_playerSync;
  _myGroup = group _playerObj;
  deleteVehicle _playerObj;
  deleteGroup _myGroup;
};

With
Code:
if (alive _playerObj) then {
  [_playerObj,nil,true] call server_playerSync;
  // spawn bot, if player in combat mode
  diag_log format["BOTLOG spawn disco_playerMorph: %1 (%2) %3", _playerObj,_playerID,_characterID];
  [_playerObj,_playerID,_characterID,30] spawn disco_playerMorph;
  _id = [_playerID,_characterID,2] spawn dayz_recordLogin;
  };

5)At your server_playerLogin (for both (A) and (B)):
Find the following line:
Code:
_worldspace = [];
Under this line, add:
Code:
if(_playerID in botPlayers) exitWith { diag_log format ["Player_have_BOT=%1",_playerID];
dayz_preloadFinished = true;
(owner _playerObj) publicVariableClient "dayz_preloadFinished";
_playerID = "";
_myGroupX = group _playerObj;
_playerObj removeAllMPEventHandlers "mpkilled";
_playerObj removeAllMPEventHandlers "mphit";
_playerObj removeAllMPEventHandlers "mprespawn";
 
_playerObj removeAllEventHandlers "FiredNear";
_playerObj removeAllEventHandlers "HandleDamage";
_playerObj removeAllEventHandlers "Killed";
_playerObj removeAllEventHandlers "Fired";
_playerObj removeAllEventHandlers "GetOut";
_playerObj removeAllEventHandlers "Local";
 
clearVehicleInit _playerObj; //let's clear all PICs
deleteVehicle _playerObj;
deleteGroup _myGroupX;
_playerObj = nil; //this seems clean even more :) thx Tansien
//deleteVehicle _playerObj;
};

6) At your server_playerLogin.sqf (for both (A) and (B))
Find the following code:
Code:
PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
(owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
Replace it with:
Code:
if(!(_playerID in botPlayers)) then {
PVCDZ_plr_Login = [_charID,_inventory,_backpack,_survival,_isNew,dayz_versionNo,_model,_isHiveOk,_newPlayer];
(owner _playerObj) publicVariableClient "PVCDZ_plr_Login";
} else {
diag_log format ["Player_have_BOT=%1",_playerID];
};

7) Now let's add a server login timer (additional 20 seconds before player will join the game).
(A)
Open the dayz_server/system/mission/init.sqf file
Find following code:
Code:
if (!isDedicated) then {
waitUntil {!isNil "dayz_loadScreenMsg"};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
if (dayz_antihack == 1) then {
[] execVM "antihack.sqf";
};
};
Replace it with:
Code:
if (!isDedicated) then {
waitUntil {!isNil "dayz_loadScreenMsg"};
_timeOut = 30;
while { _timeOut > 0 } do {
dayz_loadScreenMsg = format["Please wait %1 seconds before you can join",str(_timeOut)];
_timeOut = _timeOut - 1;
sleep 1;
};
dayz_loadScreenMsg = (localize "STR_AUTHENTICATING");
_id = player addEventHandler ["Respawn", {_id = [] spawn player_death;}];
_playerMonitor = [] execVM "\z\addons\dayz_code\system\player_monitor.sqf";
if (dayz_antihack == 1) then {
[] execVM "antihack.sqf";
};
};

(B)
Open your init.sqf (It's always located in your mission file/folder)
Find the following line
Code:
#include "\z\addons\dayz_code\system\mission\init.sqf"
Replace it with the text from the following file: http://dayz.codeit.org.ua/replace.txt

8) (OPTIONAL)
You can add the player animation like it's made in dayz origins.
Just find the following code (file: disco_playerMorph.sqf)
Code:
_newUnit setCaptive false;
below this line, add the following code:
Code:
_newUnit playmove "ActsPercMstpSnonWpstDnon_sceneBardak01";
_newUnit disableAI "MOVE";
_newUnit disableAI "FSM";

That's all. Pack back your dayz_server.pbo and run your server!

!!!
Note that when you use (B) (or mission edit) method, you shold enable edited compiles.sqf (in init.sqf), server_functions.sqf (in compiles.sqf file) and server_playerLogin.sqf/server_onPlayerDisconnect files (these two are at server_functions.sqf)

DayZ original coders for an original DiscoBot code:
http://www.dayzorigins.com/index.php?site=about
dos for testing and advicing
ua9 server players for testing


 
New Update!
VERSION 1.1 UPLOADED (only changed a discobot_files archive filelink)
Update status: IMPORTANT!
changelog:
*[FIXED] player melee weapon lost after bot despawn.
 
Back
Top