Jump to content

Trying to make a cure


DGBlackness

Recommended Posts

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)

Link to comment
Share on other sites

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).

Link to comment
Share on other sites

  • 2 months later...

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

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

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 account

Sign in

Already have an account? Sign in here.

Sign In Now
×
×
  • Create New...