messing around with recipes for different healing items and wrote 2 macro's for ease of coding,here they are,for this to work create a local variable named
and add these variables to the script or header file
add these 2 macros to the define section of your script or header file
this one checks if the player has the ingredients
this one creates the items and deletes the recipe materials
now if all the above is in the include header file all you have to add to your dialog script is this
this is super stimpak recipe from original fallout 2
for the macro has_create_ingredients list ingredients that are used from left to right,set any unused ingredient variable to -1,if you set ingredient1 to -1 and ingredient2 to a pid,this script will fail,same for one and two -1,then three a pid ect,set variable number_of_items_1 to desired number of items for the recipe for ingredient1,2 for 2 ect,variable critter is the who object to check for the items(dude_obj),number_of_items_x that ingredientx pid is set to -1 will be ignored
the macro create_healing_items is exactly the same except for item_to_make, that variable is the pid of the item to make,pretty self explanatory,critter variable is the critter to add item created to critter's inventory and delete ingredients from critter's inventory
enjoy
edit : should be noted that if the critter has tons of stuf in inventory the command rm_mult_objs_from_inven will error and not delete the items,that is a bug with the command,not the macro's,what i do to prevent this is point critter to a party member and only keep his weapon/armor and the ingredients for the recipe's in his inventory
Code:
LVAR_has_ingredients
and add these variables to the script or header file
Code:
variable new_healing_item := 0;
variable number_of_items_1 := 0;
variable number_of_items_2 := 0;
variable number_of_items_3 := 0;
variable number_of_items_4 := 0;
variable number_of_items_5 := 0;
variable ingredient_one := 0;
variable ingredient_two := 0;
variable ingredient_three := 0;
variable ingredient_four := 0;
variable ingredient_five := 0;
variable ingredient_1 := 0;
variable ingredient_2 := 0;
variable ingredient_3 := 0;
variable ingredient_4 := 0;
variable ingredient_5 := 0;
variable deleting_1 := 0;
variable deleting_2 := 0;
variable deleting_3 := 0;
variable deleting_4 := 0;
variable deleting_5 := 0;
variable delete_1 := 0;
variable delete_2 := 0;
variable delete_3 := 0;
variable delete_4 := 0;
variable delete_5 := 0;
add these 2 macros to the define section of your script or header file
this one checks if the player has the ingredients
Code:
#define has_create_ingredients(ingredient_1,ingredient_2,ingredient_3,ingredient_4,ingredient_5,critter,number_of_items_1,number_of_items_2,number_of_items_3,number_of_items_4,number_of_items_5) \
ingredient_one := obj_is_carrying_obj_pid(critter,ingredient_1); \
ingredient_two := obj_is_carrying_obj_pid(critter,ingredient_2); \
ingredient_three := obj_is_carrying_obj_pid(critter,ingredient_3); \
ingredient_four := obj_is_carrying_obj_pid(critter,ingredient_4); \
ingredient_five := obj_is_carrying_obj_pid(critter,ingredient_5); \
if(ingredient_5 != -1) then begin \
if ((ingredient_1 < number_of_items_1) or (ingredient_two < number_of_items_2) or (ingredient_three < number_of_items_3) or (ingredient_four < number_of_items_4) or (ingredient_five < number_of_items_5)) then begin \
set_local_var(LVAR_has_ingredients,0); \
end else begin \
set_local_var(LVAR_has_ingredients,1); \
end \
end else if(ingredient_4 != -1) then begin \
if ((ingredient_one < number_of_items_1) or (ingredient_two < number_of_items_2) or (ingredient_three < number_of_items_3) or (ingredient_four < number_of_items_4)) then begin \
set_local_var(LVAR_has_ingredients,0); \
end else begin \
set_local_var(LVAR_has_ingredients,1); \
end \
end else if(ingredient_3 != -1) then begin \
if ((ingredient_one < number_of_items_1) or (ingredient_two < number_of_items_2) or (ingredient_three < number_of_items_3)) then begin \
set_local_var(LVAR_has_ingredients,0); \
end else begin \
set_local_var(LVAR_has_ingredients,1); \
end \
end else if(ingredient_2 != -1) then begin \
if ((ingredient_one < number_of_items_1) or (ingredient_two < number_of_items_2)) then begin \
set_local_var(LVAR_has_ingredients,0); \
end else begin \
set_local_var(LVAR_has_ingredients,1); \
end \
end else begin \
if (ingredient_one < number_of_items_1) then begin \
set_local_var(LVAR_has_ingredients,0); \
end else begin \
set_local_var(LVAR_has_ingredients,1); \
end \
end
this one creates the items and deletes the recipe materials
Code:
#define create_healing_items(ingredient_1,ingredient_2,ingredient_3,ingredient_4,ingredient_5,item_to_make,critter,number_of_items_1,number_of_items_2,number_of_items_3,number_of_items_4,number_of_items_5) \
ingredient_one := obj_is_carrying_obj_pid(critter,ingredient_1); \
ingredient_two := obj_is_carrying_obj_pid(critter,ingredient_2); \
ingredient_three := obj_is_carrying_obj_pid(critter,ingredient_3); \
ingredient_four := obj_is_carrying_obj_pid(critter,ingredient_4); \
ingredient_five := obj_is_carrying_obj_pid(critter,ingredient_5); \
if(ingredient_5 != -1) then begin \
if (((ingredient_one / number_of_items_1) <= (ingredient_two / number_of_items_2)) and ((ingredient_one / number_of_items_1) <= (ingredient_three / number_of_items_3)) and ((ingredient_one / number_of_items_1) <= (ingredient_four / number_of_items_4)) and ((ingredient_one / number_of_items_1) <= (ingredient_five / number_of_items_5))) then begin \
new_healing_item:=(ingredient_one / number_of_items_1); \
end else if (((ingredient_two / number_of_items_2) <= (ingredient_one / number_of_items_1)) and ((ingredient_two / number_of_items_2) <= (ingredient_three / number_of_items_3)) and ((ingredient_two / number_of_items_2) <= (ingredient_four / number_of_items_4)) and ((ingredient_two / number_of_items_2) <= (ingredient_five / number_of_items_5))) then begin \
new_healing_item:=(ingredient_two / number_of_items_2); \
end else if (((ingredient_three / number_of_items_3) <= (ingredient_one / number_of_items_1)) and ((ingredient_three / number_of_items_3) <= (ingredient_two / number_of_items_2)) and ((ingredient_three / number_of_items_3) <= (ingredient_four / number_of_items_4)) and ((ingredient_three / number_of_items_3) <= (ingredient_five / number_of_items_5))) then begin \
new_healing_item:=(ingredient_three / number_of_items_3); \
end else if (((ingredient_four / number_of_items_4) <= (ingredient_one / number_of_items_1)) and ((ingredient_four / number_of_items_4) <= (ingredient_three / number_of_items_3)) and ((ingredient_four / number_of_items_4) <= (ingredient_two / number_of_items_2)) and ((ingredient_four / number_of_items_4) <= (ingredient_five / number_of_items_5))) then begin \
new_healing_item:=(ingredient_four / number_of_items_4); \
end else if (((ingredient_five / number_of_items_5) <= (ingredient_one / number_of_items_1)) and ((ingredient_five / number_of_items_5) <= (ingredient_two / number_of_items_2)) and ((ingredient_five / number_of_items_5) <= (ingredient_four / number_of_items_4)) and ((ingredient_five / number_of_items_5) <= (ingredient_three / number_of_items_3))) then begin \
new_healing_item:=(ingredient_five / number_of_items_5); \
end \
end else if(ingredient_4 != -1) then begin \
if (((ingredient_one / number_of_items_1) <= (ingredient_two / number_of_items_2)) and ((ingredient_one / number_of_items_1) <= (ingredient_three / number_of_items_3)) and ((ingredient_one / number_of_items_1) <= (ingredient_four / number_of_items_4))) then begin \
new_healing_item:=(ingredient_one / number_of_items_1); \
end else if (((ingredient_two / number_of_items_2) <= (ingredient_one / number_of_items_1)) and ((ingredient_two / number_of_items_2) <= (ingredient_three / number_of_items_3)) and ((ingredient_two / number_of_items_2) <= (ingredient_four / number_of_items_4))) then begin \
new_healing_item:=(ingredient_two / number_of_items_2); \
end else if (((ingredient_three / number_of_items_3) <= (ingredient_one / number_of_items_1)) and ((ingredient_three / number_of_items_3) <= (ingredient_two / number_of_items_2)) and ((ingredient_three / number_of_items_3) <= (ingredient_four / number_of_items_4))) then begin \
new_healing_item:=(ingredient_three / number_of_items_3); \
end else if (((ingredient_four / number_of_items_4) <= (ingredient_one / number_of_items_1)) and ((ingredient_four / number_of_items_4) <= (ingredient_three / number_of_items_3)) and ((ingredient_four / number_of_items_4) <= (ingredient_two / number_of_items_2))) then begin \
new_healing_item:=(ingredient_four / number_of_items_4); \
end \
end else if(ingredient_3 != -1) then begin \
if (((ingredient_one / number_of_items_1) <= (ingredient_two / number_of_items_2)) and ((ingredient_one / number_of_items_1) <= (ingredient_three / number_of_items_3))) then begin \
new_healing_item:=(ingredient_one / number_of_items_1); \
end else if (((ingredient_two / number_of_items_2) <= (ingredient_one / number_of_items_1)) and ((ingredient_two / number_of_items_2) <= (ingredient_three / number_of_items_3))) then begin \
new_healing_item:=(ingredient_two / number_of_items_2); \
end else if (((ingredient_three / number_of_items_3) <= (ingredient_one / number_of_items_1)) and ((ingredient_three / number_of_items_3) <= (ingredient_two / number_of_items_2))) then begin \
new_healing_item:=(ingredient_three / number_of_items_3); \
end \
end else if(ingredient_2 != -1) then begin \
if (((ingredient_one / number_of_items_1) <= (ingredient_two / number_of_items_2))) then begin \
new_healing_item:=(ingredient_one / number_of_items_1); \
end else if (((ingredient_two / number_of_items_2) <= (ingredient_one / number_of_items_1))) then begin \
new_healing_item:=(ingredient_two / number_of_items_2); \
end \
end else if(ingredient_1 != -1) then begin \
new_healing_item:=(ingredient_one / number_of_items_1); \
end \
delete_1 := obj_carrying_pid_obj(critter,ingredient_1); \
delete_2 := obj_carrying_pid_obj(critter,ingredient_2); \
delete_3 := obj_carrying_pid_obj(critter,ingredient_3); \
delete_4 := obj_carrying_pid_obj(critter,ingredient_4); \
delete_5 := obj_carrying_pid_obj(critter,ingredient_5); \
deleting_1 := rm_mult_objs_from_inven(critter,delete_1,new_healing_item * number_of_items_1); \
if(ingredient_2 != -1) then begin \
deleting_2 := rm_mult_objs_from_inven(critter,delete_2,new_healing_item * number_of_items_2); \
end \
if(ingredient_3 != -1) then begin \
deleting_3 := rm_mult_objs_from_inven(critter,delete_3,new_healing_item * number_of_items_3); \
end \
if(ingredient_4 != -1) then begin \
deleting_4 := rm_mult_objs_from_inven(critter,delete_4,new_healing_item * number_of_items_4); \
end \
if(ingredient_5 != -1) then begin \
deleting_5 := rm_mult_objs_from_inven(critter,delete_5,new_healing_item * number_of_items_5); \
end \
give_pid_qty(critter, item_to_make, new_healing_item);; \
now if all the above is in the include header file all you have to add to your dialog script is this
this is super stimpak recipe from original fallout 2
Code:
has_create_ingredients(PID_STIMPAK,PID_NUKA_COLA,PID_MUTATED_FRUIT,-1,-1,dude_obj,1,1,1,0,0);;
if(local_var(LVAR_has_ingredients) == 1) then begin
create_healing_items(PID_STIMPAK,PID_NUKA_COLA,PID_MUTATED_FRUIT,-1,-1,PID_SUPER_STIMPAK,dude_obj,1,1,1,0,0);;
end else begin
call your_dialog_node_player_does_not_have_ingredients;
end
for the macro has_create_ingredients list ingredients that are used from left to right,set any unused ingredient variable to -1,if you set ingredient1 to -1 and ingredient2 to a pid,this script will fail,same for one and two -1,then three a pid ect,set variable number_of_items_1 to desired number of items for the recipe for ingredient1,2 for 2 ect,variable critter is the who object to check for the items(dude_obj),number_of_items_x that ingredientx pid is set to -1 will be ignored
the macro create_healing_items is exactly the same except for item_to_make, that variable is the pid of the item to make,pretty self explanatory,critter variable is the critter to add item created to critter's inventory and delete ingredients from critter's inventory
enjoy
edit : should be noted that if the critter has tons of stuf in inventory the command rm_mult_objs_from_inven will error and not delete the items,that is a bug with the command,not the macro's,what i do to prevent this is point critter to a party member and only keep his weapon/armor and the ingredients for the recipe's in his inventory