antstubell Posted July 14, 2019 Share Posted July 14, 2019 Enough is enough. 4 hours on this script and can't get what I want.So far have a disease, have a treatment - lasts for 10 secs. at the moment for testing (is another disease in essence) and a cure - not hard, simple cure disease kind of thing.How 'normal' things go. Player gets disease, player needs a cure (cure disease thing) to be fully cured. In the meantime player can consume a herb to counter the diesease effect. Disease reduces health by 1 constantly until death, the herb a.k.a the treatment stops health beng reduced, currently for 10 secs. will be 1 hour when finished, All this works fine and dandy IF done this way. Of course player will encounter the herb/treatment at various times in the game and as players do will eat it to discover its effect(s) - 1 so far. Can you see the problem yet? If player does not have the disease but eats the herb/treatment then the herb/treatment gives the effect of pausing the progression of a disease the player doesn't have and at the end of the treatment DA DAH the player has the disease and thinks WTH?I need a way for the player to consume the treatment and not get a disease, that they've never encountered, at the end of the treatment.Hopefully my current script will shed some light as to where I am. Spell Property pAbilityToRemove AutoSpell Property pAbilityToAdd AutoFloat Property pHoursToWait AutoGlobalVariable Property DiseaseCured Auto; default value =0 value set by consuming cure =1GlobalVariable Property DiseaseState Auto; Value 0- never contracted 1- has disease 2- cured diseaseEvent OnUpdateGameTime(); debug.trace(self + "OnUpdateGameTime")Game.GetPlayer().RemoveSpell(pAbilityToRemove); removes disease and replaces with treatment global set to 1= has diseaseEndEvent; start timer aka disease treatmentEvent OnEffectStart(Actor akTarget, Actor akCaster)RegisterForSingleUpdateGameTime(pHourstoWait)DiseaseState.Mod(1) ; player is being treatedDebug.Notification("Treatment Started")EndEvent; stop timer aka disease treatment expiredEvent OnEffectFinish(Actor akTarget, Actor akCaster)DiseaseState.SetValue(0) ; returns to not being treatedDebug.Notification("Whitespot Has Worn Off"); disease returns if player has not already taken cureIf DiseaseCured.GetValue() != 1(Game.GetPlayer().AddSpell(pAbilityToAdd, false))EndIfEndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 14, 2019 Share Posted July 14, 2019 I would try applying a check for the DiseaseState to be at an actual value indicating that the player has the disease prior to processing the current contents of the OnEffectStart event. Also I notice that you are setting that value to 0 in the OnEffectFinish event as an indicator that the disease is no longer being treated. Yet your definition of the values indicate that 0 means that it has never been contracted, shouldn't the value then be set to 1 rather than 0. Alternatively, effects themselves can have conditions applied to them so that they do not trigger all the time. Adding a condition that checks for the disease, either the global variable or the actual effect, should work there as well. This would prevent the scripted effect from running completely until the player actually has the disease. Link to comment Share on other sites More sharing options...
Evangela Posted July 14, 2019 Share Posted July 14, 2019 (edited) Nevermind, the above poster has covered it(my post lagged for a long time). Edited July 14, 2019 by Rasikko Link to comment Share on other sites More sharing options...
antstubell Posted July 16, 2019 Author Share Posted July 16, 2019 Having a hell of a time with this, still can't work it out.The cure condition is easy, either 0 or 1, cured or not.It is all down to "Is this the first time the player has tried this treatment?" If so then don't give him the disease. In fact if the player wants to consume as many treatments as he wants, let him, just don't give him the disease.I went about this by having a global variable set to 1, not Mod(1) but SetValue(1) to indicate player has now experienced the treatment at least once whether he has the disease or not, he is at least discovering the properties of the treatment.In the disease conditions, this is where it messed up my head, I thought "Ok, I set it to !=1 is pointless because the script sets it to 1 to indicate player has eaten the herb at least once so it will always be 1 therefore no disease will be contracted... ever,"If I change the script to Mpd(1) instead of SetValue(1) to count how many times the player eats the treatment and then in disease conditions what do I check for? In fact is there any point to check for this?I can 'nutshell' it by saying "Hey treatment, I know at the end of your duration you give the player the disease IF he hasn't taken the cure (taken care of by a condition that checks player has taken cure). I also want you NOT to give the player the disease after the FIRST time the player tries the treatment for 'research' purposes or if the player doesn't have the disease but really likes eating the treatment - DON'T give him the disease. Only give him back the disease IF he already had it."Again I am staring at the script and my head hurtsHere is where I am at, I am at a loss and need a break from this, Spell Property pAbilityToRemove AutoSpell Property pAbilityToAdd AutoFloat Property pHoursToWait AutoGlobalVariable Property DiseaseCured AutoGlobalVariable Property DiseaseState AutoGlobalVariable Property WSpot1Time Auto ;player eats treatment does not have disease; Value 0- never contracted or not being treated 1- being treated 2- cured diseaseEvent OnUpdateGameTime(); debug.trace(self + "OnUpdateGameTime")Game.GetPlayer().RemoveSpell(pAbilityToRemove); removes disease and replaces with treatment global set to 1= being treatedEndEvent; start timer aka disease treatmentEvent OnEffectStart(Actor akTarget, Actor akCaster)RegisterForSingleUpdateGameTime(pHourstoWait)DiseaseState.Mod(1) ; player is being treatedDebug.Notification("Treatment Started")EndEvent; stop timer aka disease treatment expiredEvent OnEffectFinish(Actor akTarget, Actor akCaster)DiseaseState.SetValue(0) ; returns to not being treatedWSpot1Time. SetValue(1) ; player has now experienced the treatment at least onceDebug.Notification("Whitespot Has Worn Off"); disease returns if player has not already taken cure set by condition in disease form(Game.GetPlayer().AddSpell(pAbilityToAdd, false)) ; global is 1EndEvent Link to comment Share on other sites More sharing options...
IsharaMeradin Posted July 16, 2019 Share Posted July 16, 2019 How about this approach? Instead of replacing the disease and running a treatment effect and then putting the disease back. Just run the treatment effect on top of the disease. If I understand correctly, the disease causes a negative health regen so that the affected slowly loses health. The treatment should just apply a positive health regen. If affected, the two should cancel each other out. If not affected, health regen is boosted for a bit. This way you do not need to worry about the status of the disease. Link to comment Share on other sites More sharing options...
antstubell Posted July 17, 2019 Author Share Posted July 17, 2019 Ok, good idea. I'll give it a go later. I don't spend more than a couple of hours on this because it does my head in. After a while I need to be creative and landscape something. let you know what happens. Link to comment Share on other sites More sharing options...
Recommended Posts