crowdcontrolAdd(mob/Me, mob/Target, cc, time, timeReductionPercent)
// if(cc in Me.LISTcrowdcontrol)
// Me.LISTcrowdcontrol.Remove(cc)
if(ismob(Target))
Me.crowdcontrolRemove(Me, Target)
Me.LISTcrowdcontrol.Insert(1, cc)
var/Reduction = (1/100)*timeReductionPercent
sleep(time - Reduction)
Me.LISTcrowdcontrol.Remove(cc)
world<<"off"
Problem description:
Hello, I have a problem and I can't find out better idea. I want to add CC system with stuns and similar things and it would work like:
Player A stuns Player B for 3 seconds.
after 1,5 second
Player C stuns Player B for 4 seconds.
And right here the first stun should have stop working in 1,5 seconds but when player C stuns his stun is "main" one and the first one is removed.
My only idea is making a list and I have a problem with sleep proc because after 1st stun time (don't know how to put it in words) after that 3 seconds stuns it removes stun unit so, 4sec stun is being canceled before time. Please, help me :)
3 sec stun
after 1,5sec
4 sec stun <- main stun, no stacking stuns
after 4 sec
= free to go
Another way (especially to handle situations where the same effect might be applied more than once) is to use a list to contain the target's status effects, and you add and remove those effects from the list (as text strings)
With this method, there's no need to worry about stacking, you just add and remove the status strings independent of each other (it's fine to add another "copy" of the status even while the first one is active; the one with the longest duration will remain as the "main" entry)
For example:
Of course, you'd need to adopt this system to your existing procs and such.
What happens is that, based on your example:
Player A stuns Player B for 3 seconds.
after 1,5 second
Player C stuns Player B for 4 seconds.
(Player A's stun still has 1,5 seconds to go, but that won't matter, just let it go!)
after 1,5 second (total of 3 seconds)
The "stun" added by Player A is removed, but the "stun" added by Player C is still in the list.
after 2,5 seconds
Player C's "stun" is removed, Player B is no longer stunned!