@@ -191,11 +191,7 @@ void main() {
191191 #endif
192192
193193 v_endcolor_alpha.rgba = endcolor_endgameframe.rgba;
194- v_endcolor_alpha.a = clamp( (v_endcolor_alpha.a - (timeInfo.x + timeInfo.w) + 100) * 0.01, 0.0, 1.0); // fade out for end time
195-
196- float paralyzestrength = uni[instData.y].userDefined[1].x; // this (paralyzedamage/maxhealth), so >=1.0 is paralyzed
197- v_endcolor_alpha.a = clamp(pow(paralyzestrength, 2.0), 0.0, 1.1);
198- v_endcolor_alpha.r = uni[instData.y].userDefined[1].y;
194+ v_endcolor_alpha.a = uni[instData.y].userDefined[1].x;
199195
200196 // this checks the drawFlag of wether the unit is actually being drawn (this is ==1 when then unit is both visible and drawn as a full model (not icon))
201197 if ((uni[instData.y].composite & 0x00000003u) < 1u ) {
@@ -324,8 +320,20 @@ in vec4 v_endcolor_alpha;
324320out vec4 fragColor;
325321#line 25000
326322void main() {
327- float paralysis_level = v_endcolor_alpha.a; // values of 1 are fully paralyzed
328- float disarmed = v_endcolor_alpha.r; // can be 1 or 0
323+ float input_data = v_endcolor_alpha.a; // 1: para, 2: disarm, 4: fire, fraction: slow
324+ bool fire = (input_data > 3.75);
325+ if (fire) {
326+ input_data -= 4.0;
327+ }
328+ bool disarm = (input_data > 1.75);
329+ if (disarm) {
330+ input_data -= 2.0;
331+ }
332+ bool emp = (input_data > 0.75);
333+ if (emp) {
334+ input_data -= 1.0;
335+ }
336+ float slowed = input_data;
329337
330338 float noisescale;
331339 float persistance;
@@ -337,12 +345,12 @@ void main() {
337345 float lighting_sharpness;
338346 float lighting_width;
339347 float lightning_speed;
340- float effect_level;
348+ float effect_level = 0.0 ;
341349
342350 // ------------------ CONFIG START --------------------
343351
344- if (paralysis_level > 0.98 ) { // not fully paralyzed
345- effect_level = paralysis_level ;
352+ if (emp ) {
353+ effect_level = 1.0 ;
346354 noisescale = 0.31;
347355 persistance = 0.45;
348356 lacunarity = 2.5;
@@ -353,7 +361,7 @@ void main() {
353361 lighting_sharpness = 4.8;
354362 lighting_width = 3.8;
355363 lightning_speed = 0.95;
356- } else if (disarmed > 0.5 ) {
364+ } else if (disarm ) {
357365 effect_level = 0.996;
358366 noisescale = 0.31;
359367 persistance = 0.45;
@@ -365,37 +373,51 @@ void main() {
365373 lighting_sharpness = 4.8;
366374 lighting_width = 3.8;
367375 lightning_speed = 0.95;
368- } else {
369- fragColor = vec4(0);
370- return;
371376 }
372377 // ------------------ CONFIG END --------------------
373378
374- vec4 noiseposition = noisescale * vec4(v_modelPosOrig, (timeInfo.x + timeInfo.w) * lightning_speed);
375- float noise4 = 0;
376- noise4 += pow(persistance, 1.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 1.0));
377- noise4 += pow(persistance, 2.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 2.0));
378- noise4 += pow(persistance, 3.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 3.0));
379- noise4 += pow(persistance, 4.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 4.0));
380- noise4 = (1.0 * noise4 + 0.5);
381- float electricity = clamp(1.0 - abs(noise4 - 0.5) * lighting_width, 0.0, 1.0);
382- electricity = clamp(pow(electricity, lighting_sharpness), 0.0, 1.0);
383-
384- vec3 lightningcolor;
385- float effectalpha;
386- lightningcolor = mix(minlightningcolor, maxlightningcolor, electricity);
387- effectalpha = clamp(effect_level * lightningalpha, 0.0, 1.0);
379+ fragColor = vec4(1.0, 1.0, 1.0, 0.0);
388380 float flash = abs((2.0 * fract((timeInfo.x + timeInfo.w) * 0.07)) - 1.0);
389-
390- fragColor = vec4(lightningcolor, electricity*effectalpha);
391- float baseItensity = snoise(0.032 * vec4(v_modelPosOrig, 1.7*(timeInfo.x + timeInfo.w))) +
392- snoise(0.02 * vec4(v_modelPosOrig, 1.3*(timeInfo.x + timeInfo.w)));
393- baseItensity = sqrt(abs(baseItensity) + 0.2) * (0.5 * flash + 0.2) + clamp(baseItensity * (flash - 0.5) * 0.5, -0.2, 1.0);
394- wholeunitbasecolor.a = wholeunitbasecolor.a * (0.4 + baseItensity * 0.5);
395- wholeunitbasecolor.r = wholeunitbasecolor.r + baseItensity * 0.33;
396- wholeunitbasecolor.g = wholeunitbasecolor.g + baseItensity * 0.45;
397- fragColor = max(wholeunitbasecolor, fragColor); // apply whole unit base color
398- fragColor.a *= clamp((effect_level - 0.98) * 50.0, 0.0, 1.0);
381+ if (effect_level > 0.5) {
382+ vec4 noiseposition = noisescale * vec4(v_modelPosOrig, (timeInfo.x + timeInfo.w) * lightning_speed);
383+ float noise4 = 0;
384+ noise4 += pow(persistance, 1.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 1.0));
385+ noise4 += pow(persistance, 2.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 2.0));
386+ noise4 += pow(persistance, 3.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 3.0));
387+ noise4 += pow(persistance, 4.0) * snoise(noiseposition * 0.025 * pow(lacunarity, 4.0));
388+ noise4 = (1.0 * noise4 + 0.5);
389+ float electricity = clamp(1.0 - abs(noise4 - 0.5) * lighting_width, 0.0, 1.0);
390+ electricity = clamp(pow(electricity, lighting_sharpness), 0.0, 1.0);
391+
392+ vec3 lightningcolor;
393+ float effectalpha;
394+ lightningcolor = mix(minlightningcolor, maxlightningcolor, electricity);
395+ effectalpha = clamp(effect_level * lightningalpha, 0.0, 1.0);
396+
397+ fragColor = vec4(lightningcolor, electricity*effectalpha);
398+ float baseItensity = snoise(0.032 * vec4(v_modelPosOrig, 1.7*(timeInfo.x + timeInfo.w))) +
399+ snoise(0.02 * vec4(v_modelPosOrig, 1.3*(timeInfo.x + timeInfo.w)));
400+ baseItensity = sqrt(abs(baseItensity) + 0.2) * (0.5 * flash + 0.2) + clamp(baseItensity * (flash - 0.5) * 0.5, -0.2, 1.0);
401+ wholeunitbasecolor.a = wholeunitbasecolor.a * (0.4 + baseItensity * 0.5);
402+ wholeunitbasecolor.r = wholeunitbasecolor.r + baseItensity * 0.33;
403+ wholeunitbasecolor.g = wholeunitbasecolor.g + baseItensity * 0.45;
404+ fragColor = max(wholeunitbasecolor, fragColor); // apply whole unit base color
405+ fragColor.a *= clamp((effect_level - 0.98) * 50.0, 0.0, 1.0);
406+ }
407+ if (slowed > 0.001) {
408+ float baseItensity = snoise(0.032 * vec4(v_modelPosOrig, -1.7*(timeInfo.x + timeInfo.w))) +
409+ snoise(0.02 * vec4(v_modelPosOrig, -1.3*(timeInfo.x + timeInfo.w)));
410+ baseItensity = sqrt(abs(baseItensity) + 0.2);
411+ vec4 slowcolor = vec4(0.9, 0.1, 0.9, baseItensity) * sqrt(slowed) * 2.0;
412+ fragColor = mix(slowcolor, fragColor, 0.5 + 0.3 * clamp(effect_level, 0.0, 1.0));
413+ }
414+ if (fire) {
415+ flash = 1.0 - flash;
416+ float baseItensity = snoise(0.06 * vec4(v_modelPosOrig, 1.1*(timeInfo.x + timeInfo.w))) +
417+ snoise(0.073 * vec4(v_modelPosOrig, 2.2*(timeInfo.x + timeInfo.w)));
418+ vec4 firecolor = vec4(1.0, 0.3, 0.0, (0.4 + 0.3*flash) * (0.3 + 0.5 * baseItensity) + 0.2 * baseItensity + 0.4 + 0.6*flash);
419+ fragColor = mix(firecolor, fragColor, 0.65 + 0.2 * clamp(effect_level + slowed, 0.0, 1.0));
420+ }
399421}
400422]]
401423
@@ -524,7 +546,9 @@ function widget:UnitCreated(unitID, unitDefID)
524546
525547 local health ,maxHealth ,paralyzeDamage ,capture ,build = spGetUnitHealth (unitID )
526548 local disarmed = spGetUnitRulesParam (unitID , " disarmed" )
527- if (paralyzeDamage and paralyzeDamage > 0 ) or (disarmed == 1 ) then
549+ local slow = spGetUnitRulesParam (unitID , " slowState" )
550+ local fire = (spGetUnitRulesParam (unitID , " on_fire" ) == 1 )
551+ if (paralyzeDamage and paralyzeDamage > 0 ) or (disarmed == 1 ) or (slow or 0 ) > 0 or fire then
528552 DrawParalyzedUnitGL4 (unitID , unitDefID )
529553 end
530554end
@@ -542,7 +566,7 @@ function widget:UnitEnteredLos(unitID)
542566 widget :UnitCreated (unitID , spGetUnitDefID (unitID ))
543567end
544568
545- local function UnitParalyzeOrDisarmDamageEffect (unitID , unitDefID ) -- called from Healthbars Widget Forwarding GADGET!!!
569+ local function UnitStatusDamageEffect (unitID , unitDefID ) -- called from Healthbars Widget Forwarding GADGET!!!
546570 widget :UnitCreated (unitID , unitDefID )
547571end
548572
@@ -555,14 +579,18 @@ function widget:GameFrame(n)
555579 for unitID , index in pairs (paralyzedDrawUnitVBOTable .instanceIDtoIndex ) do
556580 local health , maxHealth , paralyzeDamage , capture , build = spGetUnitHealth (unitID )
557581 local disarmed = spGetUnitRulesParam (unitID , " disarmed" )
558- if (not paralyzeDamage or paralyzeDamage == 0 ) and disarmed ~= 1 then
582+ local slow = spGetUnitRulesParam (unitID , " slowState" )
583+ local fire = (spGetUnitRulesParam (unitID , " on_fire" ) == 1 )
584+ if (not paralyzeDamage or paralyzeDamage == 0 ) and disarmed ~= 1 and (slow or 0 ) <= 0 and not fire then
559585 toremove [unitID ] = true
560586 else
561587 local para = (paralyzeDamage or 0 ) / (maxHealth or 1 )
562- uniformcache [1 ] = para -- 1 to avoid div0
588+ local val = (slow or 0 )
589+ val = val + (((para >= 1 ) and 1 ) or 0 )
590+ val = val + (((disarmed == 1 ) and 2 ) or 0 )
591+ val = val + ((fire and 4 ) or 0 )
592+ uniformcache [1 ] = val
563593 gl .SetUnitBufferUniforms (unitID , uniformcache , 4 )
564- uniformcache [1 ] = disarmed
565- gl .SetUnitBufferUniforms (unitID , uniformcache , 5 )
566594 end
567595 end
568596 end
@@ -588,15 +616,19 @@ function widget:Initialize()
588616 end
589617 WG [' DrawParalyzedUnitGL4' ] = DrawParalyzedUnitGL4
590618 WG [' StopDrawParalyzedUnitGL4' ] = StopDrawParalyzedUnitGL4
591- widgetHandler :RegisterGlobal (" UnitParalyzeDamageEffect" , UnitParalyzeOrDisarmDamageEffect )
592- widgetHandler :RegisterGlobal (" UnitDisarmDamageEffect" , UnitParalyzeOrDisarmDamageEffect )
619+ widgetHandler :RegisterGlobal (" UnitParalyzeDamageEffect" , UnitStatusDamageEffect )
620+ widgetHandler :RegisterGlobal (" UnitDisarmDamageEffect" , UnitStatusDamageEffect )
621+ widgetHandler :RegisterGlobal (" UnitSlowDamageEffect" , UnitStatusDamageEffect )
622+ widgetHandler :RegisterGlobal (" UnitFireDamageEffect" , UnitStatusDamageEffect )
593623end
594624
595625function widget :Shutdown ()
596626 WG [' DrawParalyzedUnitGL4' ] = nil
597627 WG [' StopDrawParalyzedUnitGL4' ] = nil
598- widgetHandler :DeregisterGlobal (" UnitParalyzeDamageEffect" )
599- widgetHandler :DeregisterGlobal (" UnitDisarmDamageEffect" )
628+ widgetHandler :DeregisterGlobal (" UnitParalyzeDamageEffect" )
629+ widgetHandler :DeregisterGlobal (" UnitDisarmDamageEffect" )
630+ widgetHandler :DeregisterGlobal (" UnitSlowDamageEffect" )
631+ widgetHandler :DeregisterGlobal (" UnitFireDamageEffect" )
600632end
601633
602634function widget :DrawWorld ()
0 commit comments