Crafting System

Hey Allen, very nice crafting script. Best point is that I can edit it easy... My question is it possible to add a crafting menu that I can always open, for crafting that dont need fire. Like crafting bandages and matchboxes.
 
I just formatted my machine, so wont be able to get the exact code for the next few days,
But...

Have a look at the Base Building fn_SelfActions.sqf, the way it checks if you have a base building item in your inventory, if you do - then enable the menu.

You will have to do something similar, so instead of checking inflamed cursorTarget, you just check if a player is holding onto one of the items you want to use for crafting. i.e. toiletpaper, razors, if the player is holding onto this in their main inventory - then enable the menu.

This will also require modifications to the _restrictions variable in each menu as that also looks for a fire.
 
Hey Allen thx for you reply. Hmm I thought of this in the fn_SelfActions.sqf:
if(_hasToiletpaper =>4) then && _canDo && !crafting_menu_open) then {

And for the _restriction how can I change this to no restriction? Simple delete this?
Thx, greetings Don
 
Is it possible to build a house ? - From building within your db ?
If i go to 3D editor, find a house i would like to be build within the crafting system. - Would this be possible to add to the db and then the crafting system ?
 
Don't see why not, but you would have to fairly heavily modify the code.

Would it not be better to use the base building system that Damo created as a base for this?
 
Hiya! Script looks pretty good, and we are planning on modularizing our current crafting system in DayZ Sahrani.

We will be integrating it into the code, so it will be highly altered, but we figured we would see if you wanted to help out with our full coded version.

J3T, will be working on it mainly with oversight from Seven. We'd love for you to join the fray!
 
Uhhg. I'm already swamped with other work :eek:
Your free to use whatever and modify whatever, its all up to your imagination.

Speaking of imagination, I modified the crafting system to work as an AI Trader.
Basically you have AI Traders that can stand around the map that act as the activator for a menu of trade able items.


On the server side, create AI at the locations you want, then I assign a variable
in dayz_server\init\server_functions.sqf
at the end of the file, add this:
Code:
//spawn ai traders
[] execVM "\z\addons\dayz_server\compile\horror_traders.sqf";

Then inside dayz_server\compile, create a file named like the line above. In this case: horror_traders.sqf

Put this text to spawn the ai (its pretty much straight from epoch) and then a category is assigned with setVariable.

Code:
_this = createCenter resistance;
_center_1 = _this;
_group_1 = createGroup _center_1;
 
_unit_101 = objNull;
if (true) then
{
  _this = _group_1 createUnit ["SurvivorW2_DZ", [11088.3, 3315.59], [], 0, "CAN_COLLIDE"];
  _unit_101 = _this;
  _this setDir 350;
  _this setVehicleInit "this allowDammage false; this disableAI 'FSM'; _this disableAI 'ANIM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0;";
  _this setUnitAbility 0.60000002;
  _this allowDammage false; _this disableAI 'FSM'; _this disableAI 'ANIM'; _this disableAI 'MOVE'; _this disableAI 'AUTOTARGET'; _this disableAI 'TARGET'; _this setBehaviour 'SAFE'; _this forceSpeed 0;_this enableSimulation false;
  _this setVariable ["traderType","medical",true];
};
 
 
_unit_102 = objNull;
if (true) then
{
  _this = _group_1 createUnit ["Hero_1_3_DZT", [11112.4, 3342.69], [], 0, "CAN_COLLIDE"];
  _unit_102 = _this;
  _this setDir 305;
  _this setVehicleInit "this allowDammage false; this disableAI 'FSM'; _this disableAI 'ANIM'; this disableAI 'MOVE'; this disableAI 'AUTOTARGET'; this disableAI 'TARGET'; this setBehaviour 'CARELESS'; this forceSpeed 0;";
  _this setUnitAbility 0.60000002;
  _this allowDammage false; _this disableAI 'FSM'; _this disableAI 'ANIM'; _this disableAI 'MOVE'; _this disableAI 'AUTOTARGET'; _this disableAI 'TARGET'; _this setBehaviour 'CARELESS'; _this forceSpeed 0;_this enableSimulation false;
  _this setVariable ["traderType","weapons",true];
};

So basically you need to modify the skin and the position where the AI will stand, also the direction the AI will stand. Unfortunatly, I couldn't get actions to work to change their stances.

In the above example, one of the traders is medical only, and the other is weapons only.

then you need an overridden fn_selfAction.sqf,

This is the activator:
The first _aitypes variable activates that the player is in front of one of the AI Traders.
Then we read the AI variable for the category - this is just eye candy for the user.
The menu points to traderhub.sqf, the cursorTarget is sent as a parameter, so the category variable will be read again by the traderhub.

Code:
_aitypes = ["Survivor2_DZ","SurvivorW2_DZ","Hero_1_3_DZT","Bandit_1_1_DZT"];
 
    // AI Traders
    if ((typeOf cursorTarget in _aitypes) and (_cursorDistance < 5)) then {
        if (horror_traders < 0) then {
            _aitype = cursorTarget getVariable["traderType","blahblahblah"];
            switch (_aitype) do {
                case "medical": { horror_traders = player addAction [("<t color=""#FFC726"">" + ("Medical Trader") + "</t>"), "dayzhorror\tradepost\traderhub.sqf",cursorTarget, 99, false, false, "",""];};
                case "weapons": { horror_traders = player addAction [("<t color=""#FFC726"">" + ("Weapon Trader") + "</t>"), "dayzhorror\tradepost\traderhub.sqf",cursorTarget, 99, false, false, "",""];};
                case "industrial": { horror_traders = player addAction [("<t color=""#FFC726"">" + ("Industrial Trader") + "</t>"), "dayzhorror\tradepost\traderhub.sqf",cursorTarget, 99, false, false, "",""];};
                case "survival": { horror_traders = player addAction [("<t color=""#FFC726"">" + ("Survival Trader") + "</t>"), "dayzhorror\tradepost\traderhub.sqf",cursorTarget, 99, false, false, "",""];};
                default {};
            };
        };
    } else {
        player removeAction horror_traders;
        horror_traders = -1;
    };
 
traderhub.sqf:

Code:
_aitrader = _this select 3;
_category = _aitrader getVariable["traderType","blahblahblah"];
 
switch (_category) do {
    case "medical": {
        {player removeAction _x;} foreach horror_ai_trader;
        horror_ai_trader = [];
   
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  2 Toilet Paper for 1 Bandage") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Bandage","ItemBandage",1],[[0,"ItemTrashToiletpaper",2]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  1 Bandage for 2 Toilet Paper") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Toilet Paper","ItemTrashToiletpaper",2],[[0,"ItemBandage",1]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
 
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  3 Pain Killers for 1 Antibiotics") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Antibiotics","ItemAntibiotic",1],[[0,"ItemPainkiller",3]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  1 Antibiotics for 3 Pain Killers") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Pain Killers","ItemPainkiller",3],[[0,"ItemAntibiotic",1]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
   
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  2 Epinephrine for 1 Morphine") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Morphine","ItemMorphine",1],[[0,"ItemEpinephrine",2]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  1 Morphine for 2 Epinephrine") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Epinephrine","ItemEpinephrine",2],[[0,"ItemMorphine",1]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
   
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  2 Water Bottles for 1 Blood Bag") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Blood Bag","ItemBloodbag",1],[[0,"ItemWaterbottle",2]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  1 Blood Bag for 2 Water Bottles") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Water Bottle","ItemWaterbottle",2],[[0,"ItemBloodbag",1]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
   
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  4 Empty Soda for 1 Coke") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Soda - Coke","ItemSodaCoke",1],[[0,"ItemSodaEmpty",4]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
        horror_ai_trader set [count horror_ai_trader, player addaction [("<t color=""#CC9900"">" + ("  4 Empty Cans for 1 Pasta") +"</t>"),"dayzhorror\tradepost\oven.sqf",[[0,"Can - Pasta","FoodCanPasta",1],[[0,"TrashTinCan",4]]],97,false,true,"","(getPosATL player select 2) < 1 && count ((position player) nearObjects ['SurvivorW2_DZ', 5]) > 0"]];
    };
    default {};
};

The traderhub points to the oven.sqf previously define (with some minor text changes to said trading rather then crafting) and passes the menu parmeters for each trade type.

Here is an in-game screenshot (Trinity Island):

https://www.dropbox.com/s/pbt3gb38g463tmq/arma2oa 2013-07-11 22-20-29-32.png
 
BillyA, which files?

And Allen, lets get to it.

Just some base files to modify. I already have alot of edited files and want to try this by itself to see if it's something worth pursuing, without having to modify my already heavily modified files.

Thanks.
 
@BillyA, if you already have heavily modified files, then its even easier.
Make a backup in case nothing works out - and follow the instructions from Post #1.

Good Luck!
 
I have added this to my server but I am getting this error on the AI call:

Code:
16:06:38 Error in expression <mage false; this disableAI 'FSM'; _this disableAI 'ANIM'; this disableAI 'MOVE';>
16:06:38 Error position: <disableAI 'ANIM'; this disableAI 'MOVE';>
16:06:38 Error disableai: Type Array, expected Object
 
Final
oops, remove this parts from the AI server side:
_this disableAI 'ANIM';

Worked like a charm. Just not getting an option to trade tho.

Am I right in assuming that I have to change the blahblahblah in getVariable["traderType","blahblahblah"]; to one of the trader types?

Thanks
 
no, blahblahblahblah is just a default if it cannot get the variable from the AI. So the switch statements gets blahblahblah and runs the default {}; otherwise it did get a variable and runs that code within the switch.

Make sure you have the setVariable command server side.

Then if you just walk up to the different AI, you should see the "Medical" or "Weapons" etc.
Once you click on that, it should go to the next step - showing the items for that category.
 
Back
Top