Understanding reflective shader gloss?

Below is the built in reflective/specular shader. I am trying to understand which parts are using the gloss map(alpha channel of the main texture) are being used to create an effect where gloss is only applied where specified. I tried several ways of implementing this in another shader but it’s just not working. What’s up with the *= part?

Shader "Reflective/Specular" {
Properties {
	_Color ("Main Color", Color) = (1,1,1,1)
	_SpecColor ("Specular Color", Color) = (0.5, 0.5, 0.5, 1)
	_Shininess ("Shininess", Range (0.01, 1)) = 0.078125
	_ReflectColor ("Reflection Color", Color) = (1,1,1,0.5)
	_MainTex ("Base (RGB) Gloss (A)", 2D) = "white" {}
	_Cube ("Reflection Cubemap", Cube) = "_Skybox" { TexGen CubeReflect }
}
SubShader {
	LOD 300
	Tags { "RenderType"="Opaque" }

CGPROGRAM
#pragma surface surf BlinnPhong

sampler2D _MainTex;
samplerCUBE _Cube;

fixed4 _Color;
fixed4 _ReflectColor;
half _Shininess;

struct Input {
	float2 uv_MainTex;
	float3 worldRefl;
};

void surf (Input IN, inout SurfaceOutput o) {
	fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
	fixed4 c = tex * _Color;
	o.Albedo = c.rgb;
	o.Gloss = tex.a;
	o.Specular = _Shininess;
	
	fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
	reflcol *= tex.a;
	o.Emission = reflcol.rgb * _ReflectColor.rgb;
	o.Alpha = reflcol.a * _ReflectColor.a;
}
ENDCG
}

FallBack "Reflective/VertexLit"
}

Here is the alpha of your diffuse.

fixed4 tex = tex2D(_MainTex, IN.uv_MainTex);
tex.a;

The concept is simple, as your alpha is between 0 and 1 you can just multiply your cubemap by this value. With this, you can attenuate your reflection.

fixed4 reflcol = texCUBE (_Cube, IN.worldRefl);
reflcol *= tex.a;

Then you just apply your value on the Gloss to match.

o.Gloss = tex.a;

All of this gives you some colors and values (Albedo, Gloss, Specular, Emission, etc…) which are combined in the lighting function BlinnPhong.

#pragma surface surf BlinnPhong