Home » MODDING HQ 1.13 » Flugente's Magika Workshop » New Feature: Drug System Overhaul
New Feature: Drug System Overhaul[message #341541] Sun, 28 June 2015 20:38 Go to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
As previously announced, I've reworked the entire drug system. This is not optional. The old drug system no longer exists, and something better (methinks) is in place now.

Improvements are:
  • Items are no longer designated to be drugs via a special flag, like <DrugType>1081344</DrugType>. We no simply list to an entry in Drugs.xml. No more need for a calculator.
  • It is possible have several drugs with the same effect. You can now combine drug effects however you like.
  • In Drugs.xml, there were <ubDrugTravelRate>, <ubDrugWearoffRate>, <ubDrugEffect>, <ubDrugSideEffect> and <ubDrugSideEffectRate>. This was much more complicated than it should be, and has been removed.
  • Vanilla adrenaline is no longer broken. In the old system, you got a lot of APs, but all AP costs also increased, resulting in less gain.
  • Curing diseases via drugs is now much more smoothly done.
  • Internal handling of consumables (items that are consumed when we drop them onto the merc silhouette, like camo, food, drugs, clothes...) has been overhauled an centralised. Which makes finding bugs easier.
  • Any drug effect can now be applied via bullets. This means that you can now create special darts for whatever purpose you like. You can also create a shotgun that heals people, but infects them with chlamydia, if you prefer that.
  • All consumables now have a setting that determines how much of them is used in one application. You longer need to define them to be food.
  • Drugs can now give a merc an additional disability. This will work with new disabilities without extra coding.
  • Drugs can now give a merc an additional personality. This will work with new personalities without extra coding.
  • Should code be introduced that allows multiple disabilities/personalities, there would be minimal code changes required that would support this.
  • The old drug overdose effect happened only rarely. It has now been replaced by a new disease - addiction. This is a valid counter against drugs, take too many too fast and you will suffer.
  • Alcohol handling has been overhauled. In the old code certain stages of drunkenness were very hard to reach, and the effects were over very fast. A new disease - Hungover - takes care of that. Drink too much and you will feel that for hours.
  • Alcohol is now much more detailed. It takes into account the amount of pure consumed and a merc's assumed weight (big people can take more than small people). The background property 'alcohol resistance' is still used, of course.
  • Cigars and cigarettes can now be consumed. Some mercs are smokers and will do that on their own. Others are anti-smokers and dislike smokers.
  • A new disease property allows a disease to modify morale, which is made use of in 'Hungover'.
  • Note that many drugs cause diseases. Not playing with that will therefor not allow you to experience the full consequences of drugs. (Some people might prefer to simply play without the strategic disease part).
  • Various fixes.
Changed Xmls:
Food.xml:
  • <ubPortionSize> has been removed
Disease.xml:
  • <moralemodifier> has been added. This is a multiplier to total morale. If a disease has broken out, morale is modified by
    1.0f - (1.0f - moralemodifier) * (disease points / max possible disease points);
    
Backgrounds.xml:
  • <smoker> has been added, range 0 to 2. Mercs with 1 are smokers - they will occasionally consume smoke items from their inventory if found. Mercs with 2 are nonsmokers. They will refuse to smoke. Smokers and nonsmokers dislike each other. Smokers like smokers, nonsmokers like nonsmokers.
Items.xml:
  • <cigarette> has been added. Set to 1 to define cigarette items.
  • <ubPortionSize> has been moved here from Food.xml. It represents how many % of an item are consumed at once. If not set, 100 is used. Note that camo items override that setting, as the amount used is individual in that case.
  • <Alcohol> has been changed from 0/1 to FLOAT. An item with a value > 0.0 is treated as alcohol. This number is the amount of pure alcohol in g in the entire item. For example, Alcohol (item #245) has 40% alcohol and weighs 1 kg. Assuming that the glass bottle itself weighs 400g, and alcohol has a volume mass of 0.8, we calculate that it has (1000 - 400)g * 0.4 * 0.8 = 192g of alcohol. Yes it is that detailed, because you people dig detailed shit like that.
  • <DrugType> now links to Drugs.xml by number, so <DrugType>4</DrugType> links to Drug 4 in that xml. No more flags.
Drugs.xml:
  • This xml has been completely changed. There are detailed comments on how setting up a drug works no, take a look:
    <!--
    <uiIndex>				number referred to by DrugType in Items.xml
    <szName>				name of drug
    <opinionevent>			if 1, other mercs will complain about drug use
    
    There can be multiple <DRUG_EFFECT>, even of the same type.
    possible drug effects:
    		DRUG_EFFECT_HP			0
    		DRUG_EFFECT_BP			1
    		DRUG_EFFECT_AP			2
    		DRUG_EFFECT_MORALE		3
    		DRUG_EFFECT_PHYS_RES	4
    		DRUG_EFFECT_STR			5
    		DRUG_EFFECT_AGI			6
    		DRUG_EFFECT_DEX			7
    		DRUG_EFFECT_WIS			8
    
    <duration> 				is how many turns this lasts
    <size> 					is how strong the effect is. This can be positive or negative.
    If <chance> is set, this is the chance that this effect is applied when consuming drug
    
    There can be multiple <DISEASE_EFFECT>, even of the same type.
    <disease> 				refers to a disease from Disease.xml
    <size> 					is how many points are added to this disease. This can be positive (increase disease) or negative (cure disease)
    If <chance> is set, this is the chance that this effect is applied when consuming drug
    
    There can be multiple <DISABILITY_EFFECT>, even of the same type. For the duration of the effect, the merc will gain an extra disability.
    Note: Currently only one such effect per time is allowed, additional effects overwrite previous ones.
    <disability> 			refers to a disability:
    		HEAT_INTOLERANT			1
    		NERVOUS					2
    		CLAUSTROPHOBIC			3
    		NONSWIMMER				4
    		FEAR_OF_INSECTS			5
    		FORGETFUL				6
    		PSYCHO					7
    		DEAF					8
    		SHORTSIGHTED			9
    		
    <duration> 				is how many turns this lasts
    If <chance> is set, this is the chance that this effect is applied when consuming drug
    
    There can be multiple <PERSONALITY_EFFECT>, even of the same type. For the duration of the effect, the merc will gain an extra disability.
    Note: Currently only one such effect per time is allowed, additional effects overwrite previous ones.
    <personality> 			refers to a disability:
    		CHAR_TRAIT_SOCIABLE		1
    		CHAR_TRAIT_LONER		2
    		CHAR_TRAIT_OPTIMIST		3
    		CHAR_TRAIT_ASSERTIVE	4
    		CHAR_TRAIT_INTELLECTUAL	5
    		CHAR_TRAIT_PRIMITIVE	6
    		CHAR_TRAIT_AGGRESSIVE	7
    		CHAR_TRAIT_PHLEGMATIC	8
    		CHAR_TRAIT_DAUNTLESS	9
    		CHAR_TRAIT_PACIFIST		10
    		CHAR_TRAIT_MALICIOUS	11
    		CHAR_TRAIT_SHOWOFF		12
    		
    <duration> 				is how many turns this lasts
    If <chance> is set, this is the chance that this effect is applied when consuming drug
    -->
    
  • Example: the drug effect of cigars
    <DRUG>
    		<uiIndex>7</uiIndex>
    		<szName>Cigar</szName>
    		<!-- slightly lowered breath -->
    		<DRUG_EFFECT>
    			<effect>1</effect>
    			<duration>3</duration>
    			<size>-100</size>
    		</DRUG_EFFECT>
    		
    		<!-- slightly increased morale breath -->
    		<DRUG_EFFECT>
    			<effect>3</effect>
    			<duration>3</duration>
    			<size>1</size>
    		</DRUG_EFFECT>
    		
    		<!-- lung cancer -->
    		<DISEASE_EFFECT>
    			<disease>17</disease>
    			<size>100</size>
    		</DISEASE_EFFECT>	
    	</DRUG>
    	
  • Note that all these effect sizes are for the full item. If an item's <ubPortionSize> is smaller, you will only consume a fraction of that.
  • WARNING: As the xml editor does not know about these changes, it will likely destroy the xml upon reading it. Edit this xml by hand for now.
This is fully savegame compatible.
This has been added to the trunk in r7896 and GameDir r2257.
Using a new exe without the new GameDir data will cause toronto's mayor to empty your fridge.

[Updated on: Sun, 28 June 2015 23:45]




I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

Re: New Feature: Drug System Overhaul[message #341542 is a reply to message #341541] Sun, 28 June 2015 21:04 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
How does it work? An example
Let's just say that we really do want to create a machinegun that heals people and infects them with chlamydia. We also want anybody hit to sometimes become a non-swimmer. How do we do that?
Open up Drugs.xml, and start a new drug:
<DRUG>
        <uiIndex>18</uiIndex>				<!-- the number we link to in Items.xml -->
	<szName>Awesome machinegun bullets</szName>	<!-- not used anywhere, just here to help us remember what this is -->
	<opinionevent>1</opinionevent>			<!-- if set to 1 mercs will complain about anyone who 'uses' this drug - in this case the poor guy shot -->
	<DRUG_EFFECT>
		<effect>0</effect>			<!-- DRUG_EFFECT_HP: this effect will add/remove life each turn -->
		<duration>5</duration>			<!-- this will last for 5 turns (turns also happen in realtime, so this always works) -->
		<size>10</size>				<!-- heal 10 HP per turn. If you want 'poison', make that negative. -->
		<chance>100</chance>			<!-- happens 100% of the time this is applied, thereby each time a bullet hits someone (and does damage, being stopped by armour doesn't count -->
	</DRUG_EFFECT>
	<DISEASE_EFFECT>
		<disease>9</disease>			<!-- Chlamydia (see Disease.xml) -->
		<size>150</size>			<!-- Outbreak is at 300,growth per hour is 7. In a few hours, awkward questions will arise. -->
		<chance>75</chance>			<!-- Let's say this happens most of the time -->
	</DISEASE_EFFECT>
	<DISABILITY_EFFECT>
		<disability>4</disability>		<!-- Nonswimmer -->
		<duration>20</duration>			<!-- This lasts a while -->
		<chance>40</chance>			<!-- This happens sometimes -->
	</DISABILITY_EFFECT>
</DRUG>

Gorgeous! Now all that remains is too add this to some ammo in Items.xml:
<ITEM>
	<uiIndex>521</uiIndex>
	<szItemName>7.62x54R Box T</szItemName>
	<szLongItemName>7.62x54R Box, Tracer</szLongItemName>
	<szItemDesc>7.62x54R tracer rounds aid accurate burst fire.</szItemDesc>
	... boring stuff here...	
	<DrugType>18</DrugType>                          <!-- tracer ammo just got a lot more confusing -->
</ITEM>

A few important things:
  • If a drug is applied via bullets, the full drug effect (as if you were to consume it 100%).
  • The drug will only be applied if at least 1 HP damage is done (it needs contact to blood, no?).
  • This only works if your gun is loaded with this exact ammo item.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

Re: New Feature: Drug System Overhaul[message #341543 is a reply to message #341542] Mon, 29 June 2015 08:31 Go to previous messageGo to next message
smeagol is currently offline smeagol

 
Messages:2705
Registered:June 2008
Location: Bremen, Germany
Nice!


Quote:
WARNING: As the xml editor does not know about these changes, it will likely destroy the xml upon reading it. Edit this xml by hand for now.


Would be nice if someone could bring the xml-editor up to date (there are probably a lot more xml tags that are not supported anymore by the latest editor version).


Report message to a moderator

Lieutenant

Re: New Feature: Drug System Overhaul[message #341600 is a reply to message #341543] Sat, 04 July 2015 23:38 Go to previous messageGo to next message
Flugente

 
Messages:3507
Registered:April 2009
Location: Germany
Minor update: Neurotoxin darts now use the new drug system - the ammoflag-tag for them in AmmoTypes.xml is obsolete.

As this might be important to heavy users (cheeky): There can be up to 100 different drugs. If necessary, that number can be raised, though I assume this will take a while.



I know now that it could never work between us, as much as we wanted to, it could never be! Not because you're a rabbit, but because you're black.

If you want, you can donate to me. This will not affect how and what I code, and I will not code specific features in return. I will be thankful though.

Report message to a moderator

Captain

Re: New Feature: Drug System Overhaul[message #358579 is a reply to message #341600] Sun, 01 December 2019 17:19 Go to previous message
Kitty

 
Messages:473
Registered:October 2017
Location: Germany
Is it possible to add the "newer" disabilities/personality traits like

hemophilia or coward

to the possible effects?

That would be great.



How to get: latest 1.13, 7609 and more | 7609 SCI (eng) | Compiling+SVN

I need more details. (Didi Hallervorden)

Report message to a moderator

Master Sergeant
Previous Topic: New feature: individual backgrounds
Next Topic: New feature: Tripwire-triggered mines, directional mines (claymores), mines display, layered hierarc
Goto Forum:
  


Current Time: Mon Dec 02 14:59:14 GMT+2 2024

Total time taken to generate the page: 0.01087 seconds