Why hello there.
I try to script a frost spell but unfortunately I encountered a problem.
A comrade already made some good suggestions, still I haven't found any clean ways to script that spell.
First of all:
There is a initially spell which also uses a normal frost damage function from the destrcution school.
However there is also a probability of 18% that the target gets restrained (frozen).
Formerly this was solved by using "ScriptEffectStart" for setting the target to restrained and making it normal in the "ScriptEffectEnd" block.
But the problem is that with that behaviour the restrained effect is cleared if the spell is casted another time on the target and the probability failed.
So it was suggested to make another spell which controls the restrained effect with a timer.
This is the code of the first spell:
scn SpellEinfrieren18ProzentShort WahrscheinlichkeitRef Targetbegin ScriptEffectStart;InitialisierungSet Target to GetSelf;Kontrolleif (Target.isActor == 0) || (Target.getDead == 1) || (Target.isRidingHorse == 1) Returnendif;StartSet Wahrscheinlichkeit to 1 + GetRandomPercentIf ( Wahrscheinlichkeit <= 88 ) ;==>Indeed this aren't 18%. It's set up for testing.; Target.Setghost 1 if Target.IsSpellTarget 1Frostpfeil || Target.IsSpellTarget 2Frostpfeil Target.AddspellNS Eingefroren4Sek elseif Target.IsSpellTarget 3Frostpfeil || Target.IsSpellTarget 4Frostpfeil Target.AddspellNS Eingefroren5Sek elseif Target.IsSpellTarget 5Frostpfeil || Target.IsSpellTarget 6Frostpfeil || Target.IsSpellTarget 7Frostpfeil Target.AddspellNS Eingefroren6Sek endif if Target == Player Message "Sie wurden eingefroren!" else MessageEX "%n wurde eingefroren." Target endifendifend
Now there is the code for the actually freezing spell:
scn SpellEingefroren4SekEffektfloat ErstarrungsdauerRef Targetbegin ScriptEffectStart;SicherheitSet Target to GetSelfif Target.IsSpellTarget 1Frostpfeil == 0 && Target.IsSpellTarget 2Frostpfeil == 0 Set Erstarrungsdauer to -1 Target.Dispel Eingefroren4Sekendif;InitialisierungSet Erstarrungsdauer to 0;Startif Target.GetRestrained == 0 Target.PlayMagicShaderVisuals effectGefrohren SetRestrained 1endif if Target == Player DisableControl 15 DisableControl 18 DisableControl 19 DisableControl 20 DisableControl 20 DisableControl 21 DisableControl 22 DisableControl 23 DisableControl 25 endifEndBegin ScriptEffectUpdate if Erstarrungsdauer < 4 && Erstarrungsdauer != -1 Set Erstarrungsdauer to Erstarrungsdauer + ScriptEffectElapsedSeconds else Set Erstarrungsdauer to -1 if Target == Player EnableControl 15 EnableControl 18 EnableControl 19 EnableControl 20 EnableControl 21 EnableControl 22 EnableControl 23 EnableControl 24 EnableControl 25 endif SetRestrained 0 Target.RemoveSpell Eingefroren4Sek endifEndBegin ScriptEffectFinish Target.StopMagicShaderVisuals effectGefrohrenEnd
The spell is a magic ability since an illness can be transfered to the player by a simple attack of the enemy.
Somehow that code really works (it was mostly done by my comrade) but it is a very bad and unclean solution.
Since the problem is that by every new spell hit the script effect stops which actually makes me wonder that it even progress another time.
Also the spell doesn't restart if it is applied once more due a successful 18% probability.
Sometimes the magic ability even stays on the target and doesn't get cleared so there are many safety system necessary that this effect doesn't occur when it shouldn't (as seen in the start block).
Is there any way to do this cleaner?
Cheers