Disease script help

Post » Thu Jan 14, 2010 12:27 am

As far as I can tell, it seems that at least creatures and items are limited to having one script attached to them. In particular, I'm thinking about diseased and blighted creatures: they have a disease script attached to them that does all the work regarding adding a disease to the player character. As it stands: 1 script to 1 disease. I don't know how to script, but I want to change the disease script so that more than one disease could be applied to the PC.

For example, there would be a 30% chance that the script would attempt to give the player character disease A, 50% chance to try to give disease B, and 20% chance to try to give both A and B to the player character. Is such a thing possible?

Also: Misc. question: if I changed the disease spell effect to "damage attribute" from "drain attribute" would the damage magnitude be applied once (i.e. damage Agilitty 20pts; restore potions do not work until the disease has been removed, after which you can restore the attribute). Or, would be be constantly applied? (i.e. damage AGI 20pts every second)? If the former, then changing "drain" to "damage" would make diseases more challenging - not only do you need to cure it, you also have to restore your attributes.
User avatar
A Boy called Marilyn
 
Posts: 3391
Joined: Sat May 26, 2007 7:17 am

Post » Wed Jan 13, 2010 10:52 pm

i cant install it on this backup computer, so i dont have the CS open in front of me to look at it, but if memory serve, the disease scripts check for a hit on the player, and then have a chance of adding an effect (disease).

what you could then do is add a second check. if the first check (onhit check) passes, have it check another variable set to a random range in a if/elseif block. the first check determines if something is added, and the second determines what. shouldent be too hard to actually script. if you are unsure on how to script this, post a disease script up, and i'll demonstrate what i'm talking about.

as for damage vs drain, i am unsure on how it is applied. i think the reason that diseases are set to drain is that for some reason, having them set to damage allows the player to restore it and effectively be immune to that disease. i could be flat out wrong. i encourage you to experiment with it and tell us how it goes.
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm

Post » Wed Jan 13, 2010 10:29 am

Thanks, RAKNinja!

I have very little (none) skill with scripting. I can post the script, copied from the CS:
Begin diseaseAtaxiaDontSaveObjectif ( CellChanged == 0 )	returnendifif ( GetCommonDisease == 0 )	AddSpell "ataxia"endifEnd
It is for the disease Ataxia. I don't see anything that determines % chance, I think that bit is handled by the GMST "fDiseasixferChance" - the default value is 2.5000. So, the new script would need it's own % chance to determine which disease(s) get "picked" for transfer. The selected disease(s) would then be subject to the GMST (which relates to the PC's chance of catching a disease when hit). I think? :unsure:

I'll have to experiment with that, definitely - and I'll be sure to post the results. I kind of suspect other modders have had the same idea as I, and there must be a reason (i.e. the damage can get cured) that I don't see a "more deadly diseases" sort of mod. On a related note, I know there is a "cure curse" spell that is unused. I also know that when creating a new spell in the "spellmaking" tab, a new spell can be set as a "curse." I bet other modders have already experimented with this before - are curses handled like diseases? In other words, they can only be removed with the "cure curse" spell? I'm thinking it'd be kind of cool if those "cursed" items at daedric shrines actually applied curses. Or loot in ancestral tombs, you know?
User avatar
Dragonz Dancer
 
Posts: 3441
Joined: Sat Jun 24, 2006 11:01 am

Post » Wed Jan 13, 2010 10:07 pm

i havent done much work with spells, so i'm not too good with those questions, but about the script

i'm thinking getcommondisease is a global that is hard coded to get set to 1 when a disease carrying actor hits the player, the chance of this happening would be controlled by that GMST.

i surmise this script is attached to a diseased creature?

if so, what you'd want to do is simple. you would create a local variable set to a random value, and use that to determine what to add, so that your example script becomes:

Begin diseaseAtaxiaPlusDontSaveObjectshort randumbif ( CellChanged == 0 )        returnendifset randumb to (random, 11)if ( GetCommonDisease == 0 )        if ( randumb <= 5 )                AddSpell "ataxia"        elseif ( randumb <= 9 )                addspell "seconddidease"        else                addspell "thirddisease"        endifendifEnd


this sets the local variable "randumb" to a number between 1 and 10 each frame. if the disease is triggered (the getcommondisease check) the game then checks randumb. if randumb is 1-5 it gives the player ataxia. if it is 6-9 it gives the player "seconddisease" if 10 it gives a third disease instead.
User avatar
Lucky Girl
 
Posts: 3486
Joined: Wed Jun 06, 2007 4:14 pm

Post » Wed Jan 13, 2010 5:43 pm

Awesome, thanks! I'll have to test it out. To facilitate that, would I increase the GMST to 100.0000? No, wait, does 2.5 mean 2.5% or 25%? I want my character to catch the disease fast, so I don't have to get hit by a diseased guar a bazillion times to get the disease.

Also, my character has gone through the MQ and has the 100% resist common disease. Can I counter that by equipping something that gives me a weakness to disease? :unsure:
User avatar
alicia hillier
 
Posts: 3387
Joined: Tue Feb 06, 2007 2:57 am

Post » Wed Jan 13, 2010 3:31 pm

yes to weakness to disease.

what i'd do to test it is make a testing character. start a new game and make it through character creation. do a couple of console commands and set your health to something absurd and spawn a diseased creature. let him beat you up for a while.

instead of tinkering with the GMSTs, add a weakness to common disease effect on your character through the console. if you like you can even make something up in the CS with this effect, and add that to yourself though console. then script an item to spawn the appropriate creature when you equip it.

what i'd do is add such "debugging items" into a separate esp, so you dont have to worry about deleting or disabling them before public release (if any). you could then add such items into a crate near the census and excise office so you can maintain a "clean" test character save there (a save with no significant mods loaded) enable the "debug item" esp and get the stuff right there.
User avatar
Emmanuel Morales
 
Posts: 3433
Joined: Sat Oct 06, 2007 2:03 pm

Post » Thu Jan 14, 2010 1:22 am

Okay, I'm making the new scripts in the CS now. For some creatures, I only want a choice between two diseases. How would I edit the script you game me (for three diseases) so that there are two? Do I just remove
else                addspell "thirddisease"

and change "randumb "<= 9 to "randumb" <= 10 ?

See, I was reading http://www.uesp.net/wiki/Morrowind:Diseases for common diseases, and some of the in-game dialog descriptions mention some creatures (such as the alit, slaughterfish, undead, and rat) being carriers for more than one disease. I also sort of changed my mind about the idea of having a chance to catch both A and B at the same time - after all, if the player catches A and then gets hit by the creature again, there's the chance of catching disease B from randumb, right? in other words, prolonged exposure to the diseased creature increases the risk of eventually catching not just one, but also another type of disease. So, maybe it is redundant for me to have an A + B option? I also didn't see in the script you provided where I could put "firstdisease" and "seconddisease" - there's a "thirddisease" for the A + B, but I don't actually have a disease # three, I just have those two (1st and 2nd) diseases. Am I making any sense? :unsure:

And then there's this:
 Begin diseaseAscendedDontSaveObject;ascended sleeper has all the blight diseases for some reason...if ( CellChanged == 0 )	returnendifAddSpell "ash woe blight"AddSpell "black-heart blight"AddSpell "chanthrax blight"AddSpell "ash-chancre"End
for the Ascended Sleeper. I presume this just gives all the blight diseases to the player character? I think I'd want to change it so that, for each check, there's a 25% chance of getting one of the diseases, not all at the same time. Would such a script look like:
Begin diseaseAscendedPlusDontSaveObjectshort randumbif ( CellChanged == 0 )        returnendifset randumb to (random, 11)if ( GetCommonDisease == 0 )        if ( randumb <= 2)                AddSpell "ataxia"        elseif ( randumb <= 4 )                addspell "seconddidease"        elseif ( randumb <= 7 )                addspell "thirddisease"        else                addspell "fourthdisease"        endifendifEnd 


to make easy %ages, could I just set randumb to 100 and use numbers like 25, 50, 75, etc? Why is randumb set to 11? Is that because zero (0) is included as an integer? So, I'd actually want to set randumb to 101?
User avatar
Sheila Esmailka
 
Posts: 3404
Joined: Wed Aug 22, 2007 2:31 am

Post » Wed Jan 13, 2010 3:32 pm

I don't think you understand how this works. These scripts do not give the player a disease, ever. They just make sure the monster stays infected. Honestly I'm not sure why this is a problem in the first place, but in any case "catching" the disease happens automatically, no script required. The chance is controlled by a Game Setting, I believe the default value is 2.5% and it can happen either when the monster hits you or when you loot its corpse.
User avatar
Tammie Flint
 
Posts: 3336
Joined: Mon Aug 14, 2006 12:12 am

Post » Wed Jan 13, 2010 12:34 pm

I don't think you understand how this works. These scripts do not give the player a disease, ever. They just make sure the monster stays infected. Honestly I'm not sure why this is a problem in the first place, but in any case "catching" the disease happens automatically, no script required. The chance is controlled by a Game Setting, I believe the default value is 2.5% and it can happen either when the monster hits you or when you loot its corpse.

Okay, but my idea could still work, right? By adding more than one disease to the creature? I can't add more than one disease script, but I could add a script that places more than one disease "spell" for the creature to "cast" on the player? So, what would that kind of script look like? Would it just add whichever diseases I specify, and then the 2.5% is independent for each? What I mean is that if the chances are handled independently, separate chance rolls will be made for each one. The alternative would be that if the player succumbs to the 2.5% chance, he/she would automatically get all the diseases. If independent assortment, then when a check is made the player makes a save roll (so to speak) for that 2.5% chance on each disease. Which way does disease-catching-probability work? :unsure: Or am I still not quite understanding the mechanics?
User avatar
Samantha Pattison
 
Posts: 3407
Joined: Sat Oct 28, 2006 8:19 pm

Post » Wed Jan 13, 2010 6:01 pm

I think it should still work, but you'd have to remove the spells ( and it would probably be a good idea to manually reset Get*Disease ) so that it could add a new one. Otherwise, the creature will only ever get the first disease it is given.

For the random numbers, 0 is included, so to get 100 you only need random 99. The main script sets random to 101, but I don't really know why, because to my understanding it is giving you more than 100%. I know for sure that a roll of 0 counts. Using 100 ( that is, random 99 ) should give you a more fair division. You can go higher, but it apparently gets very inaccurate without some heavy math to work around it.
User avatar
Fluffer
 
Posts: 3489
Joined: Thu Jul 05, 2007 6:29 am

Post » Thu Jan 14, 2010 1:10 am

What I mean is that if the chances are handled independently, separate chance rolls will be made for each one. The alternative would be that if the player succumbs to the 2.5% chance, he/she would automatically get all the diseases

That's a good question. A quick test with an Ascended Sleeper suggests it "rolls" separately for each. That is I did not get the diseases all at once.
User avatar
Jeneene Hunte
 
Posts: 3478
Joined: Mon Sep 11, 2006 3:18 pm

Post » Wed Jan 13, 2010 6:50 pm

I think it should still work, but you'd have to remove the spells ( and it would probably be a good idea to manually reset Get*Disease ) so that it could add a new one. Otherwise, the creature will only ever get the first disease it is given.

For the random numbers, 0 is included, so to get 100 you only need random 99. The main script sets random to 101, but I don't really know why, because to my understanding it is giving you more than 100%. I know for sure that a roll of 0 counts. Using 100 ( that is, random 99 ) should give you a more fair division. You can go higher, but it apparently gets very inaccurate without some heavy math to work around it.

the last number in a range for random is never selected, so random 99 will give you a number between 0 and 98.

so random 100 really gives you 100 valid returns, 0-99.

my bad for not understanding diseases.... i rarely work with spell effects,
User avatar
Lily
 
Posts: 3357
Joined: Mon Aug 28, 2006 10:32 am

Post » Thu Jan 14, 2010 1:39 am

the last number in a range for random is never selected, so random 99 will give you a number between 0 and 98.

so random 100 really gives you 100 valid returns, 0-99.

my bad for not understanding diseases.... i rarely work with spell effects,

Wait, I knew it was all the numbers -1. I just looked up a script I have, and I used 100, not 99. I seem to have confused myself somewhere. =/ Still though, it doesn't explain why Main sets random100 to random, 101.

Alaisiagae, random numbers from a local script ( like what is on the diseased creatures ) are calculated separately ( at least as far as I have observed ), so it's more unpredictable when combined with other random calls, and probably safer as well. After all, you could have a bunch of crap happen to you at once if the global sets off a bunch of scripts.
User avatar
Rachael
 
Posts: 3412
Joined: Sat Feb 17, 2007 2:10 pm

Post » Wed Jan 13, 2010 1:47 pm

Alaisiagae, random numbers from a local script ( like what is on the diseased creatures ) are calculated separately ( at least as far as I have observed ), so it's more unpredictable when combined with other random calls, and probably safer as well. After all, you could have a bunch of crap happen to you at once if the global sets off a bunch of scripts.

I'm not quite sure what you mean. Are the globals the %chance of the GMST? :unsure: What are random calls? Is the local script the one I would be creating?

Just as a sort of proof-of-concept sort of thing, could I recycle the Ascended Sleeper disease script and put in however many common disease I wanted?
User avatar
Alina loves Alexandra
 
Posts: 3456
Joined: Mon Jan 01, 2007 7:55 pm

Post » Thu Jan 14, 2010 2:31 am

I'm not quite sure what you mean. Are the globals the %chance of the GMST? :unsure: What are random calls? Is the local script the one I would be creating?

Just as a sort of proof-of-concept sort of thing, could I recycle the Ascended Sleeper disease script and put in however many common disease I wanted?

The global I meant would be a global script. If a bunch of global scripts need a roll above 50 for something to happen, they would all happen at once if you use the global variable, random100. Random calls are every time random ( a function ) is used in a script. The script you are making would be attached to the creatures, just like the ones that already are, so yes, it is a local script. A local script has to be attached to something, otherwise it is global. The GMST doesn't affect anything but chance to catch a disease.

You could reuse the script if you aren't given every disease at once. I thought that you do get them all at once. Otherwise all you would need to do is replace the diseases with whatever you want and we wouldn't be in this mess. I'll check though, just to be sure. If that is the case, I think I know how to make it work the way you want.

But if ManaUser's test is correct, then you should be able to go on your merry way as far as I can tell.

Edit: You can certainly get more than one disease at a time. It is probably only especially noticeable with the percentage turned up, but it is possible. Like ManaUser however, I did notice that the chance is rolled separately for each disease.

So you could leave it like it is, but if the disease chance is made higher ( I tested at 25 and 100 ) it could be very dangerous for the player. If you are fine with that, then by all means go ahead. If you want to do it the the way you were before, I'll be glad to help if you need it.

Edit 2: Well, I went ahead and wrote the script anyway because I was curious. Tested and working, if you are interested.

Begin diseaseAscendedDontSaveObjectshort diseaseshort infectedfloat timer;ascended sleeper has all the blight diseases for some reason...;if ( CellChanged == 0 );	return;endif; CellChanged needs to be removed entirely, or the rest of the script won't run. It's not even needed anymore; anyway, so the whole block can be deleted.set disease to random, 100set timer to ( timer + GetSecondsPassed )if ( timer >= 5 )	RemoveSpell "ash woe blight"	RemoveSpell "black-heart blight"	RemoveSpell "chanthrax blight"	RemoveSpell "ash-chancre"	set infected to 0	set timer to 0else	returnendif ; The timer is entirely optional and adjustable. In this case it is five seconds, so the disease will be changed; every five seconds. It exists to allow the given disease a chance to infect someone, and to a lesser extent; to keep them from getting too many infections too quickly. Without it, the disease will be recaculated every; frame. You will still get a disease either way, though this will also allow the script to be slightly better on; performance. Similarly, removing the spells is optional. Without doing so though, and especially without the; timer, if the actor were to cure themselves and the script gave another disease, they could potentially get all; of the added diseases as they could all be added in as little as four frames without the timer, and still pretty; quickly with it.if ( infected != 0 )	returnendifif ( disease <= 24 )	AddSpell "ash woe blight"	set infected to 1elseif ( disease <= 49 )	AddSpell "black-heart blight"	set infected to 2elseif ( disease <= 74 )	AddSpell "chanthrax blight"	set infected to 3elseif ( disease <= 100 )	AddSpell "ash-chancre"	set infected to 4endif;infected could be set to 1 each time here, but doing it this way allows you to check which disease was added.End


With this you should be able to see how you can adapt it to every diseased creature. You may want to modify the timer to your liking, and remove the comments if you wish. If you have any further questions or need something modified let me know.
User avatar
Big mike
 
Posts: 3423
Joined: Fri Sep 21, 2007 6:38 pm


Return to III - Morrowind

cron