[Constants]
global persist $var1 = 0
global persist $var2 = 0
global persist $var3 = 0
global persist $var4 = 0
global persist $var5 = 0
global persist $var6 = 0
global $active = 0

[Present]
post $active = 0

[KeySwitchVar1]
condition = $active
Key = ctrl no_shift no_alt x
type = cycle
$var1 = 0,1,2,3,4,5,6
; Top : Org. -> Transparent (2-Step) -> Topless -> No Emblem -> No Top Deco -> No Waist Deco

[KeySwitchVar2]
condition = $active
Key = ctrl no_shift no_alt z
type = cycle
$var2 = 0,1,2,3,4
; Skirt : Org. -> Transparent (2-Step) -> No Skirt -> No Skirt Supporter

[KeySwitchVar3]
condition = $active
Key = ctrl no_shift no_alt c
type = cycle
$var3 = 0,1,2,3
; Panty/Necklace : Org. -> Panty Only -> Necklace Only -> None

[KeySwitchVar4]
condition = $active
Key = ctrl no_shift no_alt v
type = cycle
$var4 = 0,1
; Shoes : Org. -> Off

[KeySwitchVar5]
condition = $active
Key = ctrl no_shift no_alt a
type = cycle
$var5 = 0,1,2
; Arm : Org. -> No Arm Clothing -> No Armlet

[KeySwitchVar6]
condition = $active
Key = ctrl no_shift no_alt s
type = cycle
$var6 = 0,1
; Top Shape : Org. -> Malfunction

; Skirt
[TextureOverrideSkirt01]
hash = 4bcf270c
match_first_index = 6108
if ($active || $shader_type == 5)
	handling = skip
	if $var2 < 3
		ResourceBakT0 = ref ps-t0
		vb0 = ResourceSkirt1VB
		ib  = ResourceSkirt1IB
		if $var2 == 1
			ps-t0 = ResourceTextureSkirt1
		elif $var2 == 2
			ps-t0 = ResourceTextureSkirt2
		endif
		drawindexed = auto
		ps-t0 = ResourceBakT0
	endif
endif

[TextureOverrideSkirt02]
hash = 4bcf270c
match_first_index = 4542
if $var2 > 2 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirt03]
hash = 4bcf270c
match_first_index = 3156
if $var2 > 2 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirt04]
hash = 4bcf270c
match_first_index = 3906
if $var2 > 2 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirt05]
hash = 4bcf270c
match_first_index = 3567
if $var2 > 2 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirtSupporter01]
hash = 77ea1e11
match_first_index = 11808
if $var2 > 3 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirtSupporter02]
hash = 77ea1e11
match_first_index = 11616
if $var2 > 3 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSkirtSupporter03]
hash = 46da3e4e
match_first_index = 1632
if $var2 > 3 && ($active || $shader_type == 5)
	handling = skip
endif

; Top
[TextureOverrideTop01]
hash = 4bcf270c
match_first_index = 15516
if ($active || $shader_type == 5)
	handling = skip
	if $var6 > 0
		vb0 = ResourceTop1MVB
		ib  = ResourceTop1MIB
	else
		vb0 = ResourceTop1VB
		ib  = ResourceTop1IB
	endif
	if $var1 == 0
		drawindexed = auto
	elif $var1 == 1
		run = CustomShaderTransparency1
	elif $var1 == 2
		run = CustomShaderTransparency2
	endif
endif

[TextureOverrideTop02]
hash = 82feac42
match_first_index = 19818
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
elif $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
	if $var1 == 1
		run = CustomShaderTransparencyF1
	elif $var1 == 2
		run = CustomShaderTransparencyF2
	endif
endif

[TextureOverrideTop03]
hash = 4bcf270c
match_first_index = 15300
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
elif $var1 > 0 && ($active || $shader_type == 5)
	handling = skip
	if $var1 == 1
		run = CustomShaderTransparencyF1
	elif $var1 == 2
		run = CustomShaderTransparencyF2
	endif
endif

[TextureOverrideTop05]
hash = 4bcf270c
match_first_index = 24801
if ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideTopEmblem01]
hash = de954b9c
match_first_index = 312
if ($active || $shader_type == 5)
	handling = skip
	if $var1 < 4
		vb0 = ResourceTatoo2VB
		ib  = ResourceTatoo2IB
		drawindexed = auto
	endif
endif

[TextureOverrideTopEmblem02]
hash = de954b9c
match_first_index = 0
if ($active || $shader_type == 5)
	handling = skip
	if $var1 < 4
		vb0 = ResourceTatoo3VB
		ib  = ResourceTatoo3IB
		drawindexed = auto
	endif
endif

[TextureOverrideTopDeco02]
hash = 77ea1e11
match_first_index = 0
if $var1 > 4 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideTopDeco03]
hash = 82feac42
match_first_index = 4296
if $var1 > 4 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideTopDeco04]
hash = 46da3e4e
match_first_index = 0
if $var1 > 4 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideTopDeco05]
hash = 46da3e4e
match_first_index = 960
if $var1 > 4 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideWaistDeco01]
hash = 82feac42
match_first_index = 13458
if $var1 > 5 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideWaistDeco02]
hash = 82feac42
match_first_index = 5676
if $var1 > 5 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideWaistDeco03]
hash = 447d669d
match_first_index = 1680
if $var1 > 5 && ($active || $shader_type == 5)
	handling = skip
endif

; Necklace
[TextureOverrideNecklace01]
hash = 82feac42
match_first_index = 16542
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideNecklace02]
hash = 82feac42
match_first_index = 2226
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideNecklace03]
hash = 447d669d
match_first_index = 0
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
endif

; Arm
[TextureOverrideArm01]
hash = 584282d3
match_first_index = 8733
if $var5 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm02]
hash = 584282d3
match_first_index = 11583
if $var5 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm03]
hash = 584282d3
match_first_index = 13086
if $var5 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm04]
hash = 584282d3
match_first_index = 8553
if $var5 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArm05]
hash = 584282d3
match_first_index = 9093
if $var5 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmlet01]
hash = 584282d3
match_first_index = 1296
if $var5 > 1 && ($active || $shader_type == 5)
	handling = skip
elif ($active || $shader_type == 5)
	handling = skip
	vb0 = ResourceArm1VB
	ib  = ResourceArm1IB
	drawindexed = auto
endif

[TextureOverrideArmlet02]
hash = 584282d3
match_first_index = 0
if $var5 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmlet03]
hash = 4d4b6011
match_first_index = 0
if $var5 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

; Panty
[TextureOverridePanty01]
hash = 4bcf270c
match_first_index = 5202
if $var3 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverridePanty02]
hash = 4bcf270c
match_first_index = 0
if $var3 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverridePanty03]
hash = 584282d3
match_first_index = 5553
if $var3 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

; Shoes
[TextureOverrideShoes01]
hash = 82feac42
match_first_index = 8436
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes02]
hash = 82feac42
match_first_index = 19530
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes03]
hash = 82feac42
match_first_index = 18858
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes04]
hash = 82feac42
match_first_index = 762
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes05]
hash = 82feac42
match_first_index = 19146
if $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
endif

; Tatoo
[TextureOverrideTatoo01]
hash = 82feac42
match_first_index = 0
if ($active || $shader_type == 5)
	handling = skip
	vb0 = ResourceTatoo1VB
	ib  = ResourceTatoo1IB
	drawindexed = auto
endif

[TextureOverrideTatoo02]
hash = 82feac42
match_first_index = 18246
if ($active || $shader_type == 5)
	handling = skip
	vb0 = ResourceTatoo4VB
	ib  = ResourceTatoo4IB
	drawindexed = auto
endif

[TextureOverrideTatoo03]
hash = 82feac42
match_first_index = 18495
if ($active || $shader_type == 5)
	handling = skip
	vb0 = ResourceTatoo5VB
	ib  = ResourceTatoo5IB
	drawindexed = auto
endif

; Body
[TextureOverrideBody]
hash = 9f4546c7
match_first_index = 0
$active = 1
handling = skip
if $var3 > 1
	vb0 = ResourceBodyVB
	ib  = ResourceBodyIB
else
	vb0 = ResourceToplessBodyVB
	ib  = ResourceToplessBodyIB
endif
drawindexed = auto
if $var4 > 0
	vb0 = ResourceBodyF1VB
	ib  = ResourceBodyF1IB
else
	vb0 = ResourceBodyF0VB
	ib  = ResourceBodyF0IB
endif
drawindexed = auto

; Resources
[ResourceBodyVB]
type = Buffer
stride = 80
filename = resources\body.vb
[ResourceBodyIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body.ib

[ResourceToplessBodyVB]
type = Buffer
stride = 80
filename = resources\topless_body.vb
[ResourceToplessBodyIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\topless_body.ib

[ResourceBodyF0VB]
type = Buffer
stride = 80
filename = resources\body_F_0.vb
[ResourceBodyF0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_F_0.ib

[ResourceBodyF1VB]
type = Buffer
stride = 80
filename = resources\body_F_1.vb
[ResourceBodyF1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_F_1.ib

[ResourceTatoo1VB]
type = Buffer
stride = 76
filename = resources\Tatoo_1.vb
[ResourceTatoo1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Tatoo_1.ib

[ResourceTatoo2VB]
type = Buffer
stride = 72
filename = resources\Tatoo_2.vb
[ResourceTatoo2IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Tatoo_2.ib

[ResourceTatoo3VB]
type = Buffer
stride = 72
filename = resources\Tatoo_3.vb
[ResourceTatoo3IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Tatoo_3.ib

[ResourceTatoo4VB]
type = Buffer
stride = 76
filename = resources\Tatoo_4.vb
[ResourceTatoo4IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Tatoo_4.ib

[ResourceTatoo5VB]
type = Buffer
stride = 76
filename = resources\Tatoo_5.vb
[ResourceTatoo5IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Tatoo_5.ib

[ResourceTop1VB]
type = Buffer
stride = 76
filename = resources\Top_1.vb
[ResourceTop1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_1.ib

[ResourceTop1MVB]
type = Buffer
stride = 76
filename = resources\Top_1_M.vb
[ResourceTop1MIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_1_M.ib

[ResourcePanty1VB]
type = Buffer
stride = 76
filename = resources\Panty_1.vb
[ResourcePanty1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Panty_1.ib

[ResourceTop2VB]
type = Buffer
stride = 76
filename = resources\Top_2.vb
[ResourceTop2IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_2.ib

[ResourceTop3VB]
type = Buffer
stride = 60
filename = resources\top_3.vb
[ResourceTop3IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\top_3.ib

[ResourceSkirt1VB]
type = Buffer
stride = 76
filename = resources\Skirt_1.vb
[ResourceSkirt1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Skirt_1.ib

[ResourceSkirt2VB]
type = Buffer
stride = 60
filename = resources\Skirt_2.vb
[ResourceSkirt2IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Skirt_2.ib

[ResourceArm1VB]
type = Buffer
stride = 76
filename = resources\Arm_1.vb
[ResourceArm1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Arm_1.ib

[ResourceBakT0]

[ResourceTextureSkirt1]
filename = resources\texture\skirt_1.dds
[ResourceTextureSkirt2]
filename = resources\texture\skirt_2.dds

; Transparency
[CustomShaderTransparencyF1]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.5
blend_factor[1] = 0.5
blend_factor[2] = 0.5
blend_factor[3] = 1
draw = from_caller
handling = skip

[CustomShaderTransparencyF2]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.3
blend_factor[1] = 0.3
blend_factor[2] = 0.3
blend_factor[3] = 1
draw = from_caller
handling = skip

[CustomShaderTransparency1]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.5
blend_factor[1] = 0.5
blend_factor[2] = 0.5
blend_factor[3] = 1
drawindexed = auto

[CustomShaderTransparency2]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.3
blend_factor[1] = 0.3
blend_factor[2] = 0.3
blend_factor[3] = 1
drawindexed = auto