1. Check out the Store if you're looking to Buy HL2RP or other schemas for your server. You can click Buy Schemas on the very top navigation bar to visit the store.
  2. Use the Plugin Center to easily subscribe to and auto-install Clockwork plugins to your server, or submit and share plugins you have developed.
  3. Having trouble setting up or developing with Clockwork? Check out the Wiki or post in the Support Forum for advice from fellow users.
Dismiss Notice
Hi Guest, you need a Steam account to register and post on these forums. Login with Steam at the top of the forums to get started!
Dismiss Notice
Hi Guest, do you want to buy HL2RP or another Clockwork schema? Visit the Cloud Sixteen Store to get started!

[Clockwork] Diseases

Discussion in 'Plugins' started by Atebite, Jul 11, 2014.

  1. This is a thing I've been working on for a while now, and well, it's so big I figured it deserved its own thread.

    The plugin adds a disease framework to Clockwork. The framework is developer-oriented, with ease of making your own diseases in mind. The framework handles everything from incubation periods, infection, making vaccines etc. All the developer has to do is write the code for what happens to the infected.

    The plugin comes with a two diseases by default, regular cold and blindness.


    For developers

    The framework includes its own library, and a couple of hooks. Utilizing them, you can create even more powerful and influential diseases, or you can make the diseases part of anything else on the server, be it through infection by usage of items or curing all of a player's diseases as they touch an entity.

    Creating diseases

    Creating a new disease is easy, and if you've made items (I hope you have), this'll be familiar.

    Here's a skeleton for diseases:

    local DISEASE = Clockwork.disease:New("DiseaseName"); -- Create our new disease.
    DISEASE.description = "A disease."; -- The description for the disease.
    DISEASE.incubationTime = 5*60; -- The disease's incubation time in seconds. During incubation the disease is infectuous but the player will not experience symptoms.
    DISEASE.chronic = false; -- Whether or not the disease is chronic (life lasting).
    DISEASE.extraSickTime = 0; -- How much extra time in hours it'll take before a disease automatically wears off.
    DISEASE.immuneFactions = {} -- Names of factions to be immune to the disease. Characters in these factions will be made immune upon spawn.
    DISEASE.infectuous = true; -- Whether or not the disease is infectuous.
    DISEASE.transmissionType = "airborne"; -- How the disease transmits and infects others. You can pick contact, airborne or hybrid (contact & airborne mix).
    DISEASE.severity = 0; -- Severity affects how often temporary effects/symptoms occur.
    DISEASE.lethality = 0; -- Lethality (if enabled) will drain a player's health over time. Higher lethality means more damage.
    -- This is called when a player loads their character, like with incubation end, you can use this to apply appropriate visual effects.
    function DISEASE:OnInit()
    -- Executed when a player unloads their character, should be used for things like removing visual effects, etc.
    function DISEASE:OnUnload()
    -- This code is executed every single think, and is for symptoms that are constantly there.
    function DISEASE:PersistEffect(player)
    -- This code is executed only every once in a while, and is for symptoms that take place with breaks in between.
    function DISEASE:OnTemporaryEffect(player)
    -- This code is executed when the disease's incubation period ends, and can be used to apply visual effects, etc.
    function DISEASE:OnIncubationEnd(player)
    DISEASE:Register(); -- Register our disease.
    Disease library

    The class table in this library is refered to as DISEASE.

    -- A function to register a new disease.
    -- A function to set up or reset a player's disease info.
    -- A function to get whether a player is sick or not.
    -- A function to get whether a player is sick with a certain disease or not.
    Clockwork.disease:IsPlayerSickWith(player, diseaseName)
    -- A function to set a value for a player's disease info.
    Clockwork.disease:SetDiseaseData(player, key, value)
    -- A function to get a player's disease info.
    -- A function to get a player's diseases.
    -- A function to get a player's protection against infection.
    -- A function to infect a player with a disease.
    Clockwork.disease:InfectPlayer(player, diseaseName, bLog)
    -- A function to cure a player of a disease.
    Clockwork.disease:CurePlayer(player, diseaseName, bLog)
    -- A function to make a player completely healthy (cure the player of all diseases).
    Clockwork.disease:MakePlayerHealthy(player, bLog)
    -- A function to make a player immune to a disease.
    Clockwork.disease:MakePlayerImmune(player, diseaseName, bLog)
    -- A function to set a player's immunities.
    Clockwork.disease:SetPlayerImmunities(player, immunities)
    -- A function wipe all of a player's immunities.
    -- A function to execute a disease's init function.
    function Clockwork.disease:DoDiseaseInit(player, diseaseName)
    -- A function to execute a disease's unload function.
    function Clockwork.disease:DoDiseaseUnload(player, diseaseName)
    -- A function to cause a temporary effect on a player.
    Clockwork.disease:TriggerTempEffect(player, diseaseName)
    -- A function to execute the persist effect.
    Clockwork.disease:DoPersistEffect(player, diseaseName)
    -- A function to end a disease's incubation period.
    Clockwork.disease:EndIncubation(player, diseaseName)
    -- A function to get a disease as a regular table.
    -- A function to create a new vaccine based on a disease.
    -- A function to create a new pathogen syringe based on a disease.
    -- A function to register a new disease.
    Clockwork.disease:Register(data, name)
    -- A function to create a new disease.
    -- A function to get a string in uniqueID format.
    -- A function to find a disease by an identifier.
    -- A function to get all diseases.
    -- A function to create a disease contact timer.
    Clockwork.disease:ContactTimer(player, entity, delay, distance, Condition, Callback)
    Hooks (Server)

    -- Called when a player takes damage from a disease.
    function Clockwork:OnPlayerTakeDiseaseDamage(player, damageAmount, diseaseInfo) end;
    Hooks (Shared)

    -- Called when a player has their disease info established.
    function Clockwork:PlayerDiseaseInfoEstablished(player, characterDiseaseInfo) end;
    -- Called when a player is infected with a disease.
    function Clockwork:OnPlayerInfected(player, diseaseInfo) end;
    -- Called when a player's disease's incubation period ends.
    function Clockwork:OnDiseaseIncubationEnd(player, diseaseInfo) end;
    -- Called when a player experiences a temporary effect from a disease.
    function Clockwork:OnPlayerExperienceDiseaseTempEffect(player, diseaseInfo) end;
  2. TheHipster

    TheHipster rhenz is a fairly decent fellow Active Member

    Re: [Clockwork] [BETA] Diseases

    My god.. The beta and then the true release...

    The fucking hype for this has been to immense.
  3. Martz

    Martz Guest

    Re: [Clockwork] [BETA] Diseases

    And how do we make items that cure the diseases?
  4. Re: [Clockwork] [BETA] Diseases

    Read the for developers section of the thread, the library has functions that can do that.

    -- A function to cure a player of a disease.
    Clockwork.disease:CurePlayer(player, diseaseName)
    Utilize it in the item's OnUse function and there you go.
  5. Martz

    Martz Guest

    Re: [Clockwork] [BETA] Diseases

    Very well - thanks.
    May I ask what other features are you planning to add into the plugin?
  6. Re: [Clockwork] [BETA] Diseases

    A beta is supposed to be feature complete, though I still haven't added clothes being able to give you protection against being infected.

    Past that, I'd say I've thought of most things. I'm always open to ideas, though.
  7. Re: [Clockwork] [BETA] Diseases

    Can you add a way to forcefully infect someone?
  8. NightAngel

    NightAngel Fuck off Lev Active Member

    Re: [Clockwork] [BETA] Diseases

    Holy shit, this is awesome! Great work! Time to play Plague Inc in HL2RP, muahahaha. >:D

    -- A function to infect a player with a disease.
    Clockwork.disease:InfectPlayer(player, diseaseName)
    This is just a framework, so you can use this function in a command or item to forcefully infect someone. Maybe something like /cough or a /rubdirtyhandsalloversomeone command. You could also just copy the ziptie code and use that with a syringe full of a certain disease to infect someone with it.
  9. Re: [Clockwork] [BETA] Diseases

    Just a few ideas. Maybe add something that only runs once as soon as the incubation period is over.
    And something that makes a certain faction immune to the diseases.
  10. sants1

    sants1 I'm an asshole. That's all. Active Member

    Re: [Clockwork] [BETA] Diseases

    wow, an actual developer in cloudsixteen. Amazing.
    • Winner Winner x 1
  11. Re: [Clockwork] [BETA] Diseases

    I've added pathogen syringes now. Like with vaccines, they'll be made automatically.

    I can add a hook for it (when the incubation period ends), though we'll see about it being part of the disease meta.

    Also, I'll be adding factions being immune to diseases.
  12. Adler

    Adler cwSexySaveData:SaveSomePieceOfShit() Clockwork Customer Active Member

    Re: [Clockwork] [BETA] Diseases

  13. Re: [Clockwork] [BETA] Diseases

    My idea behind that hook idea is that there is one time effects like them vomiting or a screen effect being applied.

    Sweet. It would be a little silly for combine to catch a cold with them wearing there masks all day.
  14. Re: [Clockwork] [BETA] Diseases

    An update has been uploaded.


    + Added function OnIncubationEnd to the disease meta.
    + Added table immuneFactions to the disease meta.
    + Added hook Clockwork:OnDiseaseIncubationEnd(player, diseaseInfo) to shared-side.
    + Added the following functions to the disease library:
    	* Clockwork.disease:TriggerTempEffect(player, diseaseName)
    	* Clockwork.disease:EndIncubation(player, diseaseName)
    	* Clockwork.disease:DoPersistEffect(player, diseaseName)
    * Moved hook OnPlayerExperienceDiseaseTempEffect to shared-side.
    * Moved hook OnPlayerInfected to shared-side.
    * Moved hook PlayerDiseaseInfoEstablished to shared-side.
    * Disease functions are now called from shared-side.
    * Logs printed by certain library functions can now be suppressed.
    * Microoptimizations.
    Forgot to upload the code for making pathogen syringes when I left home, oops. It'll be in the next update, though.
  15. Re: [Clockwork] [BETA] Diseases

    Nice work on this Atebite, mighty generous of you to release it to the public like this :)
  16. Re: [Clockwork] [BETA] Diseases

    I somehow managed to figure out how to pull off the infection protection given by clothes at like 03:00 last night, so expect to see that in the next update.

    Looking at what I've written I feel ashamed I didn't figure it out earlier.
  17. Re: [Clockwork] [BETA] Diseases

    Update #2


    + Added clothing being able to provide additional protection against being infected when worn.
    + Added Clockwork.disease:MakePathogenSyringe(diseaseInfo).
    + Added Clockwork.disease:GetInfectionProtection(player).
    + Added a hooking to GetProgressBarInfo relating to Clockwork.disease:MakePathogenSyringe().
    - Removed the field infectionProtection from players' disease info in favor of Clockwork.disease:GetInfectionProtection().
    - Removed Clockwork.disease:MakeDrug().
    * Fixed an issue with logging.
    * Fixed Clockwork.disease:IsPlayerImmune() not checking if the player is in an immune faction.
    * Improved immunity check for Clockwork.disease:InfectPlayer().
    With this, the plugin is feature complete (I'll still take suggestions if you have any). I'm now going to focus on bugs and optimization, as well as implementing useful functions and hooks.

    A little heads up when playing with syringes containing pathogens is to make sure you're within range of whomever you're trying to inject the pathogen into, else you'll be injecting it into yourself.
  18. redaxel123

    redaxel123 Active Member

    Re: [Clockwork] [BETA] Diseases

    How do I install this do I put it in clockwork plugins or cwhl2rp plugins?
  19. redaxel123

    redaxel123 Active Member

    Re: [Clockwork] [BETA] Diseases

    Is it contagious?
  20. Re: [Clockwork] [BETA] Diseases

    Put it in the Clockwork folder's plugins, it's a Clockwork plugin.

    What do you mean?

Previous Readers (Total: 0)