phronk 895 Posted October 19, 2013 I'm starting to work on a mission that emphasizes the player character's need to survive off of scavenged food and water. However, I'm not very good at scripting. In fact, at best, I can only edit scripts and adjust them; I am not experienced enough to create my own yet. I've tried searching for good examples or templates I can at least base the script off of, but I've only come across two decent sources and they do not accomplish the system the way I'd like. Food Sources: Players would be able to obtain food items from carcasses of dead animals, inside of various buildings, and in other logical areas you'd probably scavenge for food. Water Sources: Water would be obtainable at the base/edge of water locations (ocean, ponds, lakes, rivers, etc.), water tanks, water barrels, sinks, and of course water bottles. Eating: The player will have an addAction to eat when they've obtained a food item from a food source. Drinking: The player will get an addAction to fill their water bottle when near a water source. If bottle is filled, player will get addAction to drink. I'm not quite sure if I'd need some kind of health points system for this to work with the hunger and thirst system to make sense. I might add ARP Items to the mission so I can use some of the items it adds for actual gameplay purposes, such as the food and drink items. It'd be great to get this system in the mission and have it work for multiplayer, but making scripts compatible with multiplayer is well beyond me... If anyone can help, I'd be HUGELY grateful! - Phronk Share this post Link to post Share on other sites
austin_medic 109 Posted October 19, 2013 You may need to make a GUI and some other complex stuff for it, I can do some of the basics for you and make a system that would work. first you need a variables script which will set up all the variables you need. variables.sqf thirst = 100; hunger = 100; inv_food = 0; inv_drinks = 0; You need some actions for the player to use food/drinks in units initbox (playable units) this addaction ["Eat Food",{if(inv_food > 0) then {hunger = hunger + 5 + round(random 5); }; }]; this addaction ["Drink",{if(inv_drinks > 0) then {thirst = thirst + 8 + round(random 10); }; }]; Then you need to put down some items in the editor and give them addactions this addaction ["Get Water",{inv_drinks = inv_drinks + 1}]; or this addaction ["Get Food",{inv_food = inv_food + 1}]; survival.sqf [] spawn { while{true} do { sleep 320 + random 80; if(hunger < 2) then {player setDamage 1; hint "You have starved to death.";} else { hunger = hunger - 2 - round(random 5); hint format ["Your hunger is now %1",hunger]; if (getFatigue player > 0.8) then { hunger = hunger - 2; }; if(hunger < 2) then {player setDamage 1; hint "You have starved to death.";}; if (hunger < 30) then { hint "You are starting to get hungry..."; }; if (hunger < 20) then { hint "You haven't ate anything in time and you are starting to suffer starvation."; player setFatigue 1; }; if (hunger < 10) then { hint "You are suffering from severe starvation. Find something to eat soon!"; player setFatigue 1; }; }; }; }; [] spawn { while{true} do { sleep 285 + random 65; if(thirst < 2) then {player setDamage 1; hint "You have died from dehydration.";} else { thirst = thirst - 4 - round(random 7); hint format ["Your thirst is now %1",thirst]; if (getFatigue player > 0.8) then { thirst = thirst - 3; }; if(life_thirst < 2) then {player setDamage 1; hint "You have died from dehydration.";}; if (life_thirst < 30) then { hint "You are starting to get thirsty..."; }; if (life_thirst < 20) then { hint "You haven't drank anything in time and you are starting to suffer from dehydration."; player setFatigue 1; }; if (life_thirst < 10) then { hint "You are suffering from severe dehydration. Find something to drink soon!"; player setFatigue 1; }; }; }; }; That should take care of a barebones basic coded system for it. You could probably make it cleaner and better with a dialog/display if you wanted to and knew how. Share this post Link to post Share on other sites
phronk 895 Posted October 19, 2013 Wow, that was really quick! Thanks! Works pretty well, but hunger doesn't have a maximum capacity (can go beyond 100) and is there a way to only have the Eat Food and/or Drink addActions to only appear when the player has obtained food/water, rather than as soon as the mission starts? If the player does not have food or water, he should not have the option to eat or drink. A really great start though and much better than my previous system (which didn't work). So again, thank you very much! Share this post Link to post Share on other sites
Ranwer135 308 Posted October 23, 2013 Hi. With the script, how do you put symbols for water, food, money etc on the bottom right corner of screen? Share this post Link to post Share on other sites
badessa 10 Posted July 10, 2014 Wow, that was really quick! Thanks!Works pretty well, but hunger doesn't have a maximum capacity (can go beyond 100) and is there a way to only have the Eat Food and/or Drink addActions to only appear when the player has obtained food/water, rather than as soon as the mission starts? If the player does not have food or water, he should not have the option to eat or drink. A really great start though and much better than my previous system (which didn't work). So again, thank you very much! Good morning people okay? unable to use the script, can guide me how to do?? Thanks a lot; Share this post Link to post Share on other sites