Re: ALPHA: FACTIONS Chernarus Wasteland1987 v3.7 (17.01.2015)

Posted by Oliv82 on
URL: http://kodabar-dayz-daizy-single-player-forum.163.s1.nabble.com/ALPHA-FACTIONS-Chernarus-Wasteland1987-v4-v8-16d-05-10-2018-tp18275p18982.html

if your money var is "myMoney", check if all scripts in money relation have the right "myMoney" var indeed

benevolentdevil wrote
1- how do I set it up so dead AI and Mutants drop the evCurrency and you can pick it up to add money to the myMoney variable? ( high priority this)
Most the AI/Mutants are spawned in via trigger or marker , so i need something global.
Search for the Mutants/Ai's spawning scripts, they are created by "createAgent" or "createVehicle" command
Inside those kind of scripts, you need to add "addEventHandler" command with "killed" argument

In my Wasteland mod:

_unit addEventHandler ["Killed",{[_this,"banditKills",(round(random 36))] call fnc_unitDropMoney;}];

_this is refered to the _unit
"banditKills" is the type of kill
(round(random 36)) is a randomized amount of money dropped

All those 3 arguments call another script ("scripts\compile\fn_unitDropMoney.sqf"):

_unit = _this select 0 select 0; //unit object called by _this
moneyBase = _this select 2; // in this case, (round(random 36))
_inVehicle = (vehicle _unit != _unit); // check if _unit is in veh

if (_inVehicle) then {
        _unit spawn {
                private["_unit"];
                _unit = _this;
                waitUntil {vehicle _unit == _unit}; //waiting for unit getout the veh
                sleep 2;
                _unitPos = getPosATL _unit;
                _dropMoney = "EvMoney" createVehicle _unitPos;
                if (_unitPos select 2 > 0.5) then {
                        _dropMoney modelToWorld [0,0,0];
                } else {
                        _dropMoney setPosATL _unitPos;
                };
        };
} else {
        _unitPos = getPosATL _unit;
        _dropMoney = "EvMoney" createVehicle _unitPos;
        _dropMoney setPosATL _unitPos;
};

This is the way to drop money item from a dead body with the choice of amount of money
To finish this feature, you need to add an action for your player to pickup the money item on the ground

in selfactions.sqf:

...
...
//WL1987 Pickup Money
if (_nearMoney && _canDo) then {
        if (s_player_pickupMoney < 0) then {
                s_player_pickupMoney = player addAction ["Pickup Money", "client\actions\pickupMoney.sqf"];
        };
} else {
        player removeAction s_player_pickupMoney;
        s_player_pickupMoney = -1;
};
...
...

------------------
//"pickupMoney.sqf":
------------------
_nearestMoney = (getPos player) nearestObject "EvMoney";

player removeAction s_player_pickupMoney;
//player playActionNow "medic";
player playActionNow "PutDown";
sleep 1;

_rndMoney = (round(random 10) + moneyBase);
r_player_money = r_player_money + _rndMoney; //r_player_money is "myMoney" var in your case

deleteVehicle _nearestMoney;
hint format ["You have picked up $%1",_rndMoney];
sleep 2;
_nul = [] execVM "debug\playerstats_default.sqf";


benevolentdevil wrote
 2- Is there a way to say, do that ... and have different pay outs for different things?  Like say, Blind Dog pays out 5 "myMoney" , a Zombied Stalker pays out 20 "myMoney" , AI bandits a random amount, example bandit one drops 100 "myMoney" , bandit two pays out 50 "myMoney" , bandit 3 drops 230 "myMoney"? ( lower priority this)
By checking AI's/NPC's/Mutants.. creating scripts you should set all your money amounts for each of them )

for "blindDog" spawn script:
_unit addEventHandler ["Killed",{[_this,"blindDogKill",round (random 5)] call fnc_unitDropMoney;}];

for "zombiedStalker" spawn script:
_unit addEventHandler ["Killed",{[_this,"zombiedStalkerKill",round (random 20)] call fnc_unitDropMoney;}];

for "bandit" spawn script:
_unit addEventHandler ["Killed",{[_this,"banditKill",round (random 50)] call fnc_unitDropMoney;}];
etc etc ...

-----------------------------
Dont forget to compile fnc_unitDropMoney function, somewhere in init.sqf file or something like who must be loaded in priority before starting the mission...

fnc_unitDropMoney = compile preprocessFileLineNumbers "scripts\compile\fn_unitDropMoney.sqf";