DGBlackness Posted August 25, 2013 Share Posted August 25, 2013 Hi, everyone.I'm trying to make a cure to infection... I made a txt file in /scripts with Cure, recipe etc., the main question is - how to check that player is using Cure and then remove infection? Link to comment Share on other sites More sharing options...
k12314 Posted August 25, 2013 Share Posted August 25, 2013 I think a nice hefty dose of lead into your brain will clear that right up. On the serious side of this, what do you have so far in the way of code? Walther 1 Link to comment Share on other sites More sharing options...
7Roses Posted August 25, 2013 Share Posted August 25, 2013 how to check if its been used? well first you will need to add a contextmenu (with lua code) for that item, second you should add a function to do whatever is need to be done when you click the menu (also lua code) for the adding of menu options you could take a look at ISInventoryPaneContextMenu.lua (media/lua/ISUI/ISInventoryPaneContextMenu.lua) RoboMat 1 Link to comment Share on other sites More sharing options...
RegularX Posted August 26, 2013 Share Posted August 26, 2013 I'd let you peek at the Romero's Tonic in Xmod if it was anywhere ready for consumption. But to get you down the right path: Look at how Bandages work in the current Lua files. You'll need an item, you'll need to add a hook to the ItemContextMenu, you don't need but probably should have an TimedAction to show the player using the item (which is one thing I don't have in Xmod, but is in the SICmod code). Then if you want to cure infection, the easiest way is to:getPlayer():getBodyDamage():RestoreToFullHealth();Which removes damage and infection level for all body parts. A more subtle approach (similar to how Disinfect works in SICmod) is:self.bodyPart:SetInfected(false);self.bodyPart:SetFakeInfected(false);self.character:getBodyDamage():setInf(false); self.character:getBodyDamage():setInfectionLevel(0);iow, you need to set infection level on any injured body part and the main body damage as well (AFAIK). RoboMat 1 Link to comment Share on other sites More sharing options...
commode7x Posted November 24, 2013 Share Posted November 24, 2013 I'd let you peek at the Romero's Tonic in Xmod if it was anywhere ready for consumption. But to get you down the right path: Look at how Bandages work in the current Lua files. You'll need an item, you'll need to add a hook to the ItemContextMenu, you don't need but probably should have an TimedAction to show the player using the item (which is one thing I don't have in Xmod, but is in the SICmod code). Then if you want to cure infection, the easiest way is to:getPlayer():getBodyDamage():RestoreToFullHealth();Which removes damage and infection level for all body parts. A more subtle approach (similar to how Disinfect works in SICmod) is:self.bodyPart:SetInfected(false);self.bodyPart:SetFakeInfected(false);self.character:getBodyDamage():setInf(false); self.character:getBodyDamage():setInfectionLevel(0);iow, you need to set infection level on any injured body part and the main body damage as well (AFAIK). I really wish I knew how to work the codemagic. I'm a total non-programmer, so bear with my noobishness for a moment. Essentially, I want the player to not have to apply the disinfectant on an open wound, since after bandaging it the first time, you can no longer apply disinfectant. How do I allow the player to drink the diluted bleach? I've tried to get the age-old Cure-Z and see what I could reverse engineer from that, but it's been down for near a year, now. Damnit, why is coding so hard?! It's too bad that this isn't one of those problems you can just throw money at. I've been able to narrow it down to if item:getType() == "DilutedBleach" or string.find(item:getType(),"GrainAlcohol") then if #bodyDamaged > 0 then context:addOption("Disinfect", items, SICmodUIMenu.disinfectWound, player, item); for x,y in ipairs(bodyDamaged) do subMenuDisinfect:addOption(BodyPartType.getDisplayName(y:getType()), items, SICmodUIMenu.disinfectWound, y, item); but I don't know how to get it to actually display "Disinfect" as a context menu option. Link to comment Share on other sites More sharing options...
commode7x Posted November 28, 2013 Share Posted November 28, 2013 The easy part was getting the infectionlevel lines into the right place function SICDisinfectWound:perform() self.disinfectant:Use(); self.bodyPart:SetInfected(false); self.bodyPart:SetFakeInfected(false); self.character:getBodyDamage():setInf(false); self.character:getBodyDamage():setInfectionLevel(0); self.character:getStats():setStress(self.character:getStats():getStress() + 0.15); self.character:getStats():setPain(50); ISBaseTimedAction.perform(self);end but I still can't figure out how to get a context option displayed. Link to comment Share on other sites More sharing options...
speider Posted November 28, 2013 Share Posted November 28, 2013 wow nice thread this has kinda learned me how the setsickness() stuff work:) Link to comment Share on other sites More sharing options...
Recommended Posts
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 accountSign in
Already have an account? Sign in here.
Sign In Now