[Constants]
global persist $var1 = 0
global persist $var2 = 0
global persist $var3 = 0
global persist $var4 = 0
global persist $var5 = 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
; Top : Org. -> Transparent (3-Step) -> Topless -> No Belt

[KeySwitchVar2]
condition = $active
Key = ctrl no_shift no_alt z
type = cycle
$var2 = 0,1,2,3
; Skirt/Arm Guard : Org. -> Arm Guard Only -> Skirt Only -> None

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

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

[KeySwitchVar5]
condition = $active
Key = ctrl no_shift no_alt a
type = cycle
$var5 = 0,1
; Sword : On/Off

; Skirt
[TextureOverrideSkirt01]
hash = 43ec72a7
if ($var2 == 1 || $var2 == 3)
	handling = skip
endif

[TextureOverrideSkirt02]
hash = 5ba7ed98
if ($var2 == 1 || $var2 == 3)
	handling = skip	
endif

; Arm Guard
[TextureOverrideArmGuard01]
hash = 8daba182
match_first_index = 588
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmGuard02]
hash = 8daba182
match_first_index = 204
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmGuard03]
hash = 3a93232d
match_first_index = 0
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmGuard04]
hash = fcbc8b95
match_first_index = 8760
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmGuard05]
hash = fcbc8b95
match_first_index = 23031
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideArmGuard06]
hash = 8daba182
match_first_index = 5328
if $var2 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

; Top
[TextureOverrideTop01]
hash = fcbc8b95
match_first_index = 2700
if $active
	handling = skip
	if $var1 <= 3
		vb0 = ResourceTop1VB
		ib  = ResourceTop1IB
		if $var1 == 0
			drawindexed = auto
		elif $var1 == 1
			run = CustomShaderTransparency1
		elif $var1 == 2
			run = CustomShaderTransparency2
		elif $var1 == 3
			run = CustomShaderTransparency3
		endif
	endif
	if $var2 == 0 || $var2 == 2
		vb0 = ResourceSkirtStrapVB
		ib  = ResourceSkirtStrapIB
		drawindexed = auto
	endif
endif

[TextureOverrideTop02]
hash = 8daba182
match_first_index = 0
if $var1 > 3 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideTop03]
hash = fcbc8b95
match_first_index = 18510
if $active
	if $var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)
		handling = skip
	elif $var1 > 3
		handling = skip
		vb0 = ResourceBeltVB
		ib  = ResourceBeltIB
		drawindexed = auto
	else
		handling = skip
		vb0 = ResourceTop2VB
		ib  = ResourceTop2IB
		drawindexed = auto
		vb0 = ResourceBeltVB
		ib  = ResourceBeltIB
		drawindexed = auto
	endif
endif

[TextureOverrideSword01]
hash = 22274a83
if $var5 > 0 || ($var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)) && ($active || $shader_type == 5)
	handling = skip	
endif

[TextureOverrideSword02]
hash = 38a4ff72
if $var5 > 0 || ($var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)) && ($active || $shader_type == 5)
	handling = skip	
endif

[TextureOverrideSword03]
hash = fe1fd51d
if $var5 > 0 || ($var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)) && ($active || $shader_type == 5)
	handling = skip	
endif

[TextureOverrideSword04]
hash = 8daba182
match_first_index = 1836
if $var5 > 0 || ($var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)) && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideSword05]
hash = fcbc8b95
match_first_index = 25131
if $var5 > 0 || ($var1 > 4 && $var3 > 1 && ($var2 == 1 || $var2 == 3)) && ($active || $shader_type == 5)
	handling = skip
endif

; Neck Strap
[TextureOverrideNeckStrap01]
hash = fcbc8b95
match_first_index = 27447
if ($var3 == 1 || $var3 == 3) && ($active || $shader_type == 5)
	handling = skip
endif

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

; Stocking/Shoes
[TextureOverrideStocking01]
hash = fcbc8b95
match_first_index = 29445
pre ResourceVS = ref vs-cb2
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
elif $var4 > 0 && ($active || $shader_type == 5)
	handling = skip
	vb0 = ResourceSockVB
	ib  = ResourceSockIB
	drawindexed = auto
endif

[TextureOverrideShoes01]
hash = fcbc8b95
match_first_index = 12960
if ($active || $shader_type == 5)
	handling = skip
	if $var4 <= 1
		vb0 = ResourceShoesStrapVB
		ib  = ResourceShoesStrapIB
		drawindexed = auto
	endif
	if ($var2 == 0 || $var2 == 2)
		vb0 = ResourceSkirtRibbonVB
		ib  = ResourceSkirtRibbonIB
		drawindexed = auto
	endif
endif

[TextureOverrideShoes02]
hash = 8daba182
match_first_index = 6864
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

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

[TextureOverrideShoes04]
hash = fcbc8b95
match_first_index = 17748
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes05]
hash = fcbc8b95
match_first_index = 25995
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

[TextureOverrideShoes06]
hash = 3a93232d
match_first_index = 702
if $var4 > 1 && ($active || $shader_type == 5)
	handling = skip
endif

; Body
[TextureOverrideBody]
hash = f9399f32
match_first_index = 0
$active = 1
handling = skip
vb0 = ResourceBodyVB
ib  = ResourceBodyIB
drawindexed = auto
if $var2 > 1
	vb0 = ResourceBodyA1VB
	ib  = ResourceBodyA1IB
else
	vb0 = ResourceBodyA0VB
	ib  = ResourceBodyA0IB
endif
drawindexed = auto
if $var4 > 0
	vb0 = ResourceBodyL1VB
	ib  = ResourceBodyL1IB
else
	vb0 = ResourceBodyL0VB
	ib  = ResourceBodyL0IB
endif
drawindexed = auto
if $var4 > 1
	ResourceBakVS = ref vs-cb2
	vs-cb2 = ResourceVS
	vb0 = ResourceBodyFVB
	ib  = ResourceBodyFIB
	drawindexed = auto
	vs-cb2 = ResourceBakVS
endif

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

[ResourceBodyIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body.ib

[ResourceBodyFVB]
type = Buffer
stride = 80
filename = resources\body_F.vb

[ResourceBodyFIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_F.ib

[ResourceBodyA0VB]
type = Buffer
stride = 80
filename = resources\body_A_0.vb

[ResourceBodyA0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_A_0.ib

[ResourceBodyA1VB]
type = Buffer
stride = 80
filename = resources\body_A_1.vb

[ResourceBodyA1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_A_1.ib

[ResourcebodyL0VB]
type = Buffer
stride = 80
filename = resources\body_L_0.vb

[ResourcebodyL0IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_0.ib

[ResourcebodyL1VB]
type = Buffer
stride = 80
filename = resources\body_L_1.vb

[ResourcebodyL1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\body_L_1.ib

[ResourceShoesStrapVB]
type = Buffer
stride = 76
filename = resources\Shoes_strap.vb

[ResourceShoesStrapIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Shoes_strap.ib

[ResourceSkirtStrapVB]
type = Buffer
stride = 76
filename = resources\skirt_strap.vb

[ResourceSkirtStrapIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\skirt_strap.ib

[ResourceSkirtRibbonVB]
type = Buffer
stride = 76
filename = resources\Skirt_Ribbon.vb

[ResourceSkirtRibbonIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Skirt_Ribbon.ib

[ResourceBeltVB]
type = Buffer
stride = 76
filename = resources\Belt.vb

[ResourceBeltIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Belt.ib

[ResourceTop1VB]
type = Buffer
stride = 76
filename = resources\Top_1.vb

[ResourceTop1IB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\Top_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

[ResourceSockVB]
type = Buffer
stride = 76
filename = resources\sock.vb

[ResourceSockIB]
type = Buffer
format = DXGI_FORMAT_R16_UINT
filename = resources\sock.ib

[ResourceVS]
[ResourceBakVS]
[ResourceBakT0]
[ResourceBakT1]
[ResourceBakT2]

; Transparency
[CustomShaderTransparency3]
blend[0] = ADD BLEND_FACTOR INV_BLEND_FACTOR
blend_factor[0] = 0.6
blend_factor[1] = 0.6
blend_factor[2] = 0.6
blend_factor[3] = 1
drawindexed = auto

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

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