Jump to content

Put coins on AI?


Recommended Posts

Where would you put it in here for example?

if (isServer) then {

	private ["_aitype","_mission","_aipack","_aicskill","_position","_unitnumber","_skill","_gun","_mags","_backpack","_skin","_gear","_aiweapon","_aigear","_aiskin","_skillarray","_unitGroup","_weapon","_magazine","_weaponandmag","_gearmagazines","_geartools","_unit"];

	_position 			= _this select 0;
	_unitnumber 		= _this select 1;
	_skill 				= _this select 2;
	_gun 				= _this select 3;
	_mags 				= _this select 4;
	_backpack 			= _this select 5;
	_skin 				= _this select 6;
	_gear 				= _this select 7;
	_aitype				= _this select 8;
	
	if (count _this > 9) then {
		_mission = _this select 9;
	} else {
		_mission = false;
	};

	_aiweapon 			= [];
	_aigear 			= [];
	_aiskin 			= "";
	_aicskill 			= [];
	_aipack 			= "";
	_skillarray 		= ["aimingAccuracy","aimingShake","aimingSpeed","endurance","spotDistance","spotTime","courage","reloadSpeed","commanding","general"];
	_unitGroup 			= createGroup east;
	_current_time		= time;

	for "_x" from 1 to _unitnumber do {

		switch (_gun) do {
			case 0 : {_aiweapon = ai_wep_assault;};
			case 1 : {_aiweapon = ai_wep_machine;};
			case 2 : {_aiweapon = ai_wep_sniper;};
			case "Random" : {_aiweapon = ai_wep_random call BIS_fnc_selectRandom;};
		};

		_weaponandmag 	= _aiweapon call BIS_fnc_selectRandom;
		_weapon 		= _weaponandmag select 0;
		_magazine 		= _weaponandmag select 1;

		switch (_gear) do {
			case 0 : {_aigear = ai_gear0;};
			case 1 : {_aigear = ai_gear1;};
			case 2 : {_aigear = ai_gear2;};
			case 3 : {_aigear = ai_gear3;};
			case 4 : {_aigear = ai_gear4;};
			case "Random" : {_aigear = ai_gear_random call BIS_fnc_selectRandom;};
		};
		
		_gearmagazines = _aigear select 0;
		_geartools = _aigear select 1;

		if (_skin == "Random") then {
			_aiskin = ai_skin call BIS_fnc_selectRandom;
		} else {
			_aiskin = _skin;
		};

		_unit = _unitGroup createUnit [_aiskin, [(_position select 0),(_position select 1),(_position select 2)], [], 10, "PRIVATE"];
		[_unit] joinSilent _unitGroup;

		switch (_aitype) do {
			case "Bandit":	{ _unit setVariable ["humanity", ai_add_humanity, true]; };
			case "Hero":	{ _unit setVariable ["humanity", -ai_remove_humanity, true]; };
		};

		if (_backpack == "Random") then {
			_aipack = ai_packs call BIS_fnc_selectRandom;
		} else {
			_aipack = _backpack;
		};
		
		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

		if (sunOrMoon != 1) then {
			_unit addweapon "NVGoggles";
		};

		for "_i" from 1 to _mags do {
			_unit addMagazine _magazine;
		};
		
		_unit addBackpack _aipack;

		{
			_unit addMagazine _x
		} foreach _gearmagazines;

		{
			_unit addweapon _x
		} foreach _geartools;
		
		switch (_skill) do {
			case "easy"		: { _aicskill = ai_skill_easy; };
			case "medium" 	: { _aicskill = ai_skill_medium; };
			case "hard" 	: { _aicskill = ai_skill_hard; };
			case "extreme" 	: { _aicskill = ai_skill_extreme; };
			case "Random" 	: { _aicskill = ai_skill_random call BIS_fnc_selectRandom; };
			default { _aicskill = ai_skill_random call BIS_fnc_selectRandom; };
		};

		{
			_unit setSkill [(_x select 0),(_x select 1)]
		} foreach _aicskill;
		
		ai_ground_units = (ai_ground_units + 1);

		_unit addEventHandler ["Killed",{[_this select 0, _this select 1, "ground"] call on_kill;}];

		if (_mission) then {
			_unit setVariable ["missionclean", "ground"];
		};

	};
	// Stops them from killing eachother when they fire..
	_unitGroup setFormation "ECH LEFT";

	_unitGroup selectLeader ((units _unitGroup) select 0);

	[_unitGroup, _position, _mission] call group_waypoints;

	diag_log format ["WAI: Spawned a group of %1 bandits at %2", _unitnumber, _position];

};
Link to comment
Share on other sites

change

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

to 

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

                // Soul Hive
		_unit setVariable["CashMoney",5000,true];
                // 999 Hive
                _unit setVariable["headShots",5000,true];

Or how much cash u want, i put 5000 now, change that number to your likings

 

 

If u want like random generated cash try this:

 

Between 0 to 20000 ( always +1000)


		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;


                _cash = round(random 20) * 1000; // number between 0 and 20 000

                // Soul Hive
		_unit setVariable["CashMoney",_cash ,true];
                // 999 Hive
                _unit setVariable["headShots",_cash ,true];
Link to comment
Share on other sites

  • 1 month later...
  • 3 weeks later...

Hello,

I have DZMS and WAI and DZAI running on my server I would like to give my AI gold coins but I am not sure what file I need to edit, I have looked for a file similar to the one above but do not see one anywhere, so I guess my question is, where do I change this?

 

For WAI look for a file called "spawn_group.sqf"  I don't use DZMS so I do not know what the file is named.  Maybe for DZAI you can add the changes in the file called "fn_createGroup.sqf"

Link to comment
Share on other sites

  • 2 weeks later...

Got it working on DZMS but i cannot find the right file for DZAI.

Also is it possible to have some sort of chance in it, so not all the AI have coins on them?

 

I did a DZMS mission (have _cash = round(random 20) * 100; to make the amount random) and was pretty rich after just one mission.

Or should i just lower the _cash?

Link to comment
Share on other sites

Got it working on DZMS but i cannot find the right file for DZAI.

Also is it possible to have some sort of chance in it, so not all the AI have coins on them?

 

I did a DZMS mission (have _cash = round(random 20) * 100; to make the amount random) and was pretty rich after just one mission.

Or should i just lower the _cash?

Anyone?

Link to comment
Share on other sites

Also is it possible to have some sort of chance in it, so not all the AI have coins on them?

 

Yes. Not hard at all.

 

Take your script that adds coins, and add this around it:

_coinsRandom = random 1;
if (_coinsRandom <= 0.5) then {
	[your code here]
};

So this has a 50% chance of adding coins to your AI. If you want to change it just change "0.5" to something else.

Link to comment
Share on other sites

Should add it underneath this?

//Add weapon, ammunition, and backpack
_magazine = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines") select 0;
_unit addMagazine _magazine;
_unit addWeapon _weapon;
_unit selectWeapon _weapon;
_unit addBackpack _backpack;
if ((getNumber (configFile >> "CfgWeapons" >> _weapon >> "type")) == 2) then {_unit setVariable ["CanGivePistol",false]};
if ((getNumber (configFile >> "CfgMagazines" >> _magazine >> "count")) < 8) then {_unit addMagazine _magazine};
Link to comment
Share on other sites

//Add weapon, ammunition, and backpack
_magazine = getArray (configFile >> "CfgWeapons" >> _weapon >> "magazines") select 0;
_unit addMagazine _magazine;
_unit addWeapon _weapon;
_unit selectWeapon _weapon;
_unit addBackpack _backpack;
_cash = round(random 20) * 300; // number between 0 and 20 000

                // Soul Hive
_unit setVariable["CashMoney",_cash ,true];
Link to comment
Share on other sites

 

change

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

to 

		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;

                // Soul Hive
		_unit setVariable["CashMoney",5000,true];
                // 999 Hive
                _unit setVariable["headShots",5000,true];

Or how much cash u want, i put 5000 now, change that number to your likings

 

 

If u want like random generated cash try this:

 

Between 0 to 20000 ( always +1000)


		_unit enableAI "TARGET";
		_unit enableAI "AUTOTARGET";
		_unit enableAI "MOVE";
		_unit enableAI "ANIM";
		_unit enableAI "FSM";
		_unit setCombatMode ai_combatmode;
		_unit setBehaviour ai_behaviour;
		removeAllWeapons _unit;
		removeAllItems _unit;
		_unit addweapon _weapon;


                _cash = round(random 20) * 1000; // number between 0 and 20 000

                // Soul Hive
		_unit setVariable["CashMoney",_cash ,true];
                // 999 Hive
                _unit setVariable["headShots",_cash ,true];

Hi all!

 

Does this also work for DZAI ?

Link to comment
Share on other sites

  • 3 weeks later...

WAI:

 

spawn_group.sqf

 

Find

call {
      if(_aitype == "hero")         exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; };
      if(_aitype == "bandit")     exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; };
      if(_aitype == "special")     exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; };
     };

Replace with

call {
      if(_aitype == "hero")  exitWith { _unit setVariable ["Hero",true]; _unit setVariable ["humanity", ai_remove_humanity]; _unit setVariable ["cashMoney", ai_hero_amount]; };
      if(_aitype == "bandit")  exitWith { _unit setVariable ["Bandit",true]; _unit setVariable ["humanity", ai_add_humanity]; _unit setVariable ["cashMoney", ai_bandit_amount]; };
      if(_aitype == "special")  exitWith { _unit setVariable ["Special",true]; _unit setVariable ["humanity", ai_special_humanity]; _unit setVariable ["cashMoney", ai_special_amount]; };
     };

on_kill.sqf

 

Add

_playerCoins    = _player getVariable["cashMoney",0];
_unitCoins      = _unit   getVariable["cashMoney",0];
Under
_banditkills    = _player getVariable["banditKills",0];
_humankills     = _player getVariable["humanKills",0];

Add

if (ai_coin_award) then {
     _player setVariable ["cashMoney",(_playerCoins + _unitCoins),true];
};

Under

if (ai_humanity_gain) then {
     _gain = _unit getVariable ["humanity", 0];
     call {
        if (_unit getVariable ["Hero", false]) exitWith { _player setVariable ["humanity",(_humanity - _gain),true]; };
        if (_unit getVariable ["Bandit", false]) exitWith { _player setVariable ["humanity",(_humanity + _gain),true]; }; 
        if (_unit getVariable ["Special", false]) exitWith { if (_humanity < 0) then { _player setVariable ["humanity",(_humanity - _gain),true]; } else { _player setVariable ["humanity",(_humanity + _gain),true]; }; };
    };
};

Config.sqf

 

Add

ai_coin_award = true;
ai_hero_amount = 200;
ai_bandit_amount = 200;
ai_special_amount = 300;

Change the values to what you want. 

 

Under

ai_special_humanity = 150;

If your using an older version of SC then change 'cashMoney' to 'headShots'

 

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
×
×
  • Create New...