Jump to content

How to give the zombie gold?


Recommended Posts

edit your zombie_generate.sqf

private ["_position","_unitTypes","_radius","_method","_agent"];

_position = _this select 0;
_doLoiter = _this select 1; // wander around
_unitTypes = _this select 2; // class of wanted models
_maxControlledZombies = round(dayz_maxLocalZombies);

_cantSee = {
	private ["_isok"];

	_isok = true;
	_zPos = +(_this select 0);
	if (count _zPos < 3) exitWith {
		diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos];
		false
	};
	_zPos = ATLtoASL _zPos;
	_fov = _this select 1; // players half field of view
	_safeDistance = _this select 2; // minimum distance. closer is wrong
	_farDistance = _this select 3; // distance further we won't check
	_zPos set [2, (_zPos select 2) + 1.7];
	{
		_xasl = getPosASL _x;
		if (_xasl distance _zPos < _farDistance) then {
			if (_xasl distance _zPos < _safeDistance) then {
				_isok = false;
			}
			else {
				_eye = eyePos _x; // ASL
				_ed = eyeDirection _x;
				_ed = (_ed select 0) atan2 (_ed select 1);
				_deg = [_xasl, _zPos] call BIS_fnc_dirTo;
				_deg = (_deg - _ed + 720) % 360;
				if (_deg > 180) then { _deg = _deg - 360; };
				if ((abs(_deg) < _fov) && {( // in right angle sector?
						(!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
						&& {(!(lineIntersects [_zPos, _eye]))}) // && no object between?
					)}) then {
					_isok = false;
				};
			};
		};
		if (!_isok) exitWith {false};
	} count playableUnits;

	_isok
};

if ((dayz_spawnZombies < _maxControlledZombies) && (dayz_CurrentNearByZombies < dayz_maxNearByZombies) && (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
	if ([_position, dayz_cantseefov, 10, dayz_cantseeDist] call _cantSee) then {
		//Check if anyone close
		_tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
		if (_tooClose) exitwith {
			// diag_log ("Zombie_Generate: was too close to player.");
		};

		//Add zeds if unitTypes equals 0
		if (count _unitTypes == 0) then {
			if (DZE_MissionLootTable) then {
				_unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
			} else {
				_unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
			};
		};

		// lets create an agent
		_type = _unitTypes call BIS_fnc_selectRandom;
		_radius = 5;
		_method = "NONE";
		if (_doLoiter) then {
			_radius = 40;
			_method = "CAN_COLLIDE";
		};

		//Check if point is in water
		if (surfaceIsWater _position) exitwith {  };

		_agent = createAgent [_type, _position, [], _radius, _method];
		sleep 0.001;

		//add to global counter
		dayz_spawnZombies = dayz_spawnZombies + 1;

		//Add some loot
		_loot = "";
		_array = [];
		_rnd = random 1;
		if (_rnd < 0.2) then {
			_lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
			if (isText _lootType) then {
				_array = [];
				{
					_array set [count _array, _x select 0]
				} forEach getArray (configFile >> "cfgLoot" >> getText(_lootType));
				if (count _array > 0) then {
					_index = dayz_CLBase find getText(_lootType);
					_weights = dayz_CLChances select _index;
					_loot = _array select (_weights select (floor(random (count _weights))));
					if(!isNil "_array") then {
						_loot_count =	getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
						if(_loot_count>1) then {
							_agent addMagazine [_loot, ceil(random _loot_count)];
						} else {
						_agent addMagazine _loot;
						};
					};
				};
			};
		};

		_agent setVariable["agentObject",_agent];

		if (!isNull _agent) then {
			// sometime Z can be seen flying in very high speed while tp. Its altitude is set underground to hide that.
			/*
			_agtPos = getPosASL _agent;
			_agtPos set [2, -3];
			_agent setPosASL _agtPos;
			sleep 0.001;
			_agtPos = +(_position);
			_agtPos set [2, -3];
			_agent setPosASL _agtPos;
			sleep 0.001;
			*/
			_agent setDir random 360;
			//_agent setPosATL _position;
			sleep 0.001;

			_position = getPosATL _agent;

			_favStance = (
				switch ceil(random(3^0.5)^2) do {
					//case 3: {"DOWN"}; // prone
					case 2: {"Middle"}; // Kneel
					default {"UP"} // stand-up
				}
			);
			_agent setUnitPos _favStance;

			_agent setVariable ["stance", _favStance];
			_agent setVariable ["BaseLocation", _position];
			_agent setVariable ["doLoiter", true]; // true: Z will be wandering, false: stay still
			_agent setVariable ["myDest", _position];
			_agent setVariable ["newDest", _position];

// COINS HERE
_agent setVariable ["cashMoney", 500]; 
//

			[_agent, _position] call zombie_loiter;
		};
		//add to monitor
		//dayz_zedMonitor set [count dayz_zedMonitor, _agent];

		//Disable simulation
		PVDZE_Server_Simulation = [_agent, false];
		publicVariableServer "PVDZE_Server_Simulation";

		//Start behavior
		_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
	};
};

Link to comment
Share on other sites

 

edit your zombie_generate.sqf

private ["_position","_unitTypes","_radius","_method","_agent"];

_position = _this select 0;
_doLoiter = _this select 1; // wander around
_unitTypes = _this select 2; // class of wanted models
_maxControlledZombies = round(dayz_maxLocalZombies);

_cantSee = {
	private ["_isok"];

	_isok = true;
	_zPos = +(_this select 0);
	if (count _zPos < 3) exitWith {
		diag_log format["%1::_cantSee illegal pos %2", __FILE__, _zPos];
		false
	};
	_zPos = ATLtoASL _zPos;
	_fov = _this select 1; // players half field of view
	_safeDistance = _this select 2; // minimum distance. closer is wrong
	_farDistance = _this select 3; // distance further we won't check
	_zPos set [2, (_zPos select 2) + 1.7];
	{
		_xasl = getPosASL _x;
		if (_xasl distance _zPos < _farDistance) then {
			if (_xasl distance _zPos < _safeDistance) then {
				_isok = false;
			}
			else {
				_eye = eyePos _x; // ASL
				_ed = eyeDirection _x;
				_ed = (_ed select 0) atan2 (_ed select 1);
				_deg = [_xasl, _zPos] call BIS_fnc_dirTo;
				_deg = (_deg - _ed + 720) % 360;
				if (_deg > 180) then { _deg = _deg - 360; };
				if ((abs(_deg) < _fov) && {( // in right angle sector?
						(!(terrainIntersectASL [_zPos, _eye]) // no terrain between?
						&& {(!(lineIntersects [_zPos, _eye]))}) // && no object between?
					)}) then {
					_isok = false;
				};
			};
		};
		if (!_isok) exitWith {false};
	} count playableUnits;

	_isok
};

if ((dayz_spawnZombies < _maxControlledZombies) && (dayz_CurrentNearByZombies < dayz_maxNearByZombies) && (dayz_currentGlobalZombies < dayz_maxGlobalZeds)) then {
	if ([_position, dayz_cantseefov, 10, dayz_cantseeDist] call _cantSee) then {
		//Check if anyone close
		_tooClose = {isPlayer _x} count (_position nearEntities ["CAManBase",30]) > 0;
		if (_tooClose) exitwith {
			// diag_log ("Zombie_Generate: was too close to player.");
		};

		//Add zeds if unitTypes equals 0
		if (count _unitTypes == 0) then {
			if (DZE_MissionLootTable) then {
				_unitTypes = []+ getArray (missionConfigFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
			} else {
				_unitTypes = []+ getArray (configFile >> "CfgBuildingLoot" >> "Default" >> "zombieClass");
			};
		};

		// lets create an agent
		_type = _unitTypes call BIS_fnc_selectRandom;
		_radius = 5;
		_method = "NONE";
		if (_doLoiter) then {
			_radius = 40;
			_method = "CAN_COLLIDE";
		};

		//Check if point is in water
		if (surfaceIsWater _position) exitwith {  };

		_agent = createAgent [_type, _position, [], _radius, _method];
		sleep 0.001;

		//add to global counter
		dayz_spawnZombies = dayz_spawnZombies + 1;

		//Add some loot
		_loot = "";
		_array = [];
		_rnd = random 1;
		if (_rnd < 0.2) then {
			_lootType = configFile >> "CfgVehicles" >> _type >> "zombieLoot";
			if (isText _lootType) then {
				_array = [];
				{
					_array set [count _array, _x select 0]
				} forEach getArray (configFile >> "cfgLoot" >> getText(_lootType));
				if (count _array > 0) then {
					_index = dayz_CLBase find getText(_lootType);
					_weights = dayz_CLChances select _index;
					_loot = _array select (_weights select (floor(random (count _weights))));
					if(!isNil "_array") then {
						_loot_count =	getNumber(configFile >> "CfgMagazines" >> _loot >> "count");
						if(_loot_count>1) then {
							_agent addMagazine [_loot, ceil(random _loot_count)];
						} else {
						_agent addMagazine _loot;
						};
					};
				};
			};
		};

		_agent setVariable["agentObject",_agent];

		if (!isNull _agent) then {
			// sometime Z can be seen flying in very high speed while tp. Its altitude is set underground to hide that.
			/*
			_agtPos = getPosASL _agent;
			_agtPos set [2, -3];
			_agent setPosASL _agtPos;
			sleep 0.001;
			_agtPos = +(_position);
			_agtPos set [2, -3];
			_agent setPosASL _agtPos;
			sleep 0.001;
			*/
			_agent setDir random 360;
			//_agent setPosATL _position;
			sleep 0.001;

			_position = getPosATL _agent;

			_favStance = (
				switch ceil(random(3^0.5)^2) do {
					//case 3: {"DOWN"}; // prone
					case 2: {"Middle"}; // Kneel
					default {"UP"} // stand-up
				}
			);
			_agent setUnitPos _favStance;

			_agent setVariable ["stance", _favStance];
			_agent setVariable ["BaseLocation", _position];
			_agent setVariable ["doLoiter", true]; // true: Z will be wandering, false: stay still
			_agent setVariable ["myDest", _position];
			_agent setVariable ["newDest", _position];

// COINS HERE
_agent setVariable ["cashMoney", 500]; 
//

			[_agent, _position] call zombie_loiter;
		};
		//add to monitor
		//dayz_zedMonitor set [count dayz_zedMonitor, _agent];

		//Disable simulation
		PVDZE_Server_Simulation = [_agent, false];
		publicVariableServer "PVDZE_Server_Simulation";

		//Start behavior
		_id = [_position,_agent] execFSM "\z\AddOns\dayz_code\system\zombie_agent.fsm";
	};
};

Unable to use

Link to comment
Share on other sites

Insta award for zombie killing?

 

edit local_eventKill.sqf

 

 
private ["_zed","_killer","_kills","_array","_type","_humanity"];
 
_array =  _this select 0;
_zed =  _array select 0;
_killer =  _array select 1;
_type =  _this select 1;
 
if (local _zed) then {
_kills = _killer getVariable[_type,0];
_killer setVariable[_type,(_kills + 1),true];
 
//increase players humanity when zed killed
_humanity = _killer getVariable["humanity",0];
_humanity = _humanity + 5;
_killer setVariable["humanity",_humanity,true];
 
//Zombie kill award
_killCash = _killer getVariable["cashMoney",0];
_killer setVariable["cashMoney",(_killCash + 20),true];
 
//                                                                         ^
//                                                 Change value to what you want.
 
};

Link to comment
Share on other sites

 

It does.

 

 

change this:

_killer = setVariable["cashMoney",(_killCash + 20),true];

remove the "=" so it looks like:

_killer setVariable["cashMoney",(_killCash + 20),true];

 

Ah, Thanks. I should read what i type x]

Link to comment
Share on other sites

  • 3 weeks later...

the Insta award for zombie killing doesn't work for me is this coded for 1.1 2.0 or 3.0?

 

Never mind I got it fixed. For the people that use it the way its put. if it doesn't work change the lowercase c to an uppercase C

was the only issue lol took me 12 hours to figure it out. lame.

 

_killCash = _killer getVariable["cashMoney",0];
_killer setVariable["cashMoney",(_killCash + 20),true];
 
_killCash = _killer getVariable["CashMoney",0];
_killer setVariable["CashMoney",(_killCash + 20),true];
Link to comment
Share on other sites

  • 5 months later...

change the study body check to allow Zeds to :) in selfactions.

 

Comon guys ^^ some logical thinking!! 

 

I won't be always here to aswer these things

Can you show how to add this to the self actions please? Thanks in advance!! 

Link to comment
Share on other sites

Anyone ever get this working? I can't get the wallet to show up. Seems like zombies are already added to the study body in fn_selfactions.

 

*****************I figured it out.

 

Change

 

if (_isMan && !_isZombie && !_isAnimal) then {

 

to this

 

if ((_isMan || _isZombie) && !_isAnimal) then {

Link to comment
Share on other sites

  • 5 months later...

What peipo set but explained abt more in detail.

When u spawn the ai object thens et the variable:
 

// _aiObject is the ai guy.

_aiObject setVariable["CashMoney",5000];

I think you can get some the coin code to the ai loadouts should work i done this be for work time to time but no errors shown 

Link to comment
Share on other sites

  • 1 year later...
On 12/3/2014 at 3:24 PM, escortrally said:

It does.

 

 

change this:


_killer = setVariable["cashMoney",(_killCash + 20),true];

remove the "=" so it looks like:


_killer setVariable["cashMoney",(_killCash + 20),true];

I am unable to get this to work. here is the error I get.

 8:25:13 Error in expression <"humanity",_humanity,true];


_killCash _killer getVariable["CashMoney",0];
_kil>
 8:25:13   Error position: <_killer getVariable["CashMoney",0];
_kil>
 8:25:13   Error Missing ;
 8:25:13 File mpmissions\__cur_mp.napf\custom\local_eventKill.sqf, line 21

I have all the ; in there? this line here,  private ["_zed","_killer","_kills","_array","_type","_humanity"]; Do you need to add "_killCash" to it?

Link to comment
Share on other sites

16 minutes ago, DAKA said:

So I have tried the other method and can't get that to work either. Not sure what I am doing wrong, 

Ok, So I got this to work finally, here is what my line looks like,

if (_isMan && _isZombie && !_isAnimal) then {

I took out the ! in front of isZombie and it worked just fine.

Link to comment
Share on other sites

  • 2 months later...
  • 8 months later...

how would you add animals to this? it works on zeds but was wondering for hunter kill payout for hunting each type of wild animals

 

private ["_zed","_killer","_kills","_array","_type","_humanity"];
 
_array =  _this select 0;
_zed =  _array select 0;
_killer =  _array select 1;
_type =  _this select 1;
 
if (local _zed) then {
_kills = _killer getVariable[_type,0];
_killer setVariable[_type,(_kills + 1),true];
 
//increase players humanity when zed killed
_humanity = _killer getVariable["humanity",0];
_humanity = _humanity + 1;
_killer setVariable["humanity",_humanity,true];
 
//Zombie kill award
_killCash = _killer getVariable["cashMoney",0];
_killer setVariable["cashMoney",(_killCash + 100),true];
 "Zombie Bounty Reward $100" call dayz_rollingMessages;
};
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...