enum {
	RES_RAREARMOR,
	RES_SUPERARMOR,
	RES_MEDKITSTORE,
	RES_ACCESSORY,
	
	RES_FLECHETTE,
	RES_PIERCING,
	RES_ELECTRIC,
    RES_NITRO,
	RES_SLUGSHELL,
	
	RES_SONICGRENADE,
	RES_HEGRENADE,
	
	RES_DOUBLESPECIALCAP,
	
	RES_SLOT1OCCULT,
	RES_SLOT2LUXURY,
	RES_SLOT3LUXURY,
	RES_SLOT4LUXURY,
	RES_SLOT5LUXURY,
	RES_SLOT6LUXURY,
	RES_SLOT7LUXURY,
	
	RES_SLOT1UPG1,
	RES_SLOT1UPG2,
	
	RES_SLOT2UPG1,
	RES_SLOT2UPG2,
	
	RES_SLOT3UPG1,
    RES_SLOT3UPG2,
	RES_SLOT3UPG3,
	RES_SLOT3UPG4,
	
	RES_SLOT3SSGUPG1,
	RES_SLOT3SSGUPG2,
	RES_SLOT3SSGUPG3,
	RES_SLOT3SSGUPG4,
	
	RES_SLOT4UPG1,
    RES_SLOT4UPG2,
	RES_SLOT4UPG3,
	RES_SLOT4UPG4,
	RES_SLOT4UPG5,
	
	RES_SLOT5UPG1,
	RES_SLOT5GL,
	RES_SLOT5UPG2,
	RES_SLOT5UPG3,
	RES_SLOT5UPG4,
	RES_SLOT5UPG5,
	
	RES_SLOT6UPG1,
    RES_SLOT6UPG2,
	RES_SLOT6UPG3,
	RES_SLOT6UPG4,
	
	RES_SLOT7UPG1,
	RES_SLOT7UPG2,
	
	RES_OCCULTABILITY,
	RES_SLOT8REVEAL,
	RES_NANOTECH,
	RES_OCCULTARTIFACT,
	
	RES_BIO1,
	RES_BIO2,
	RES_BIO3,
	RES_EXO1,
	RES_EXO2,
	RES_EXO3,
	RES_IMP1,
	RES_IMP2,
	RES_IMP3,
	
	RES_STASHTAB
};

Actor TechLevel : Ammo {
	inventory.amount 1
	inventory.maxamount 30
	+IGNORESKILL
}

Actor StoredMedkit : Ammo {
	inventory.amount 1
	inventory.maxamount 100
	ammo.backpackamount 0
	ammo.backpackmaxamount 100
	+IGNORESKILL
}

Actor MedkitItem : CustomInventory {
	inventory.maxamount 1
	inventory.icon "PORMEICO"
	+INVENTORY.INVBAR
	+INVENTORY.UNDROPPABLE
	inventory.amount 1
	inventory.maxamount 16000
	States {
		Use:
			MEDI A 0 A_JumpIfInventory("StoredMedkit", 1, "TryHeal")
		End:
			TNT1 A 0
			Fail
		TryHeal:
			TNT1 A 0 A_JumpIf(ACS_NamedExecuteWithResult("DnD Can Pick Health Item", 2), "DoHeal")
			Goto End
		DoHeal:
			TNT1 A 0 A_PlaySound("Items/fieldkit")
			TNT1 A 0 ACS_NamedExecuteWithResult("DnD Portable Kit Script")
			Fail
	}
}

Actor Research_Discovered_1 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

Actor Research_Discovered_2 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

Actor Research_Discovered_3 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

Actor Research_Done_1 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

Actor Research_Done_2 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

Actor Research_Done_3 : Inventory {
	inventory.maxamount 0x7FFFFFFF
}

// ****************************
//		DEPENDENCY TRACKERS
// ****************************

Actor Research_Slot3Upgrade3_Tracker : Ammo {
	inventory.amount 1
	inventory.maxamount 5000
	ammo.backpackamount 0
	ammo.backpackmaxamount 5000
	+IGNORESKILL
}

// track player finding 25000 health collect
Actor Research_Body_Hp_1_Tracker : Ammo {
	inventory.amount 1
	inventory.maxamount 25000
	ammo.backpackamount 0
	ammo.backpackmaxamount 25000
	+IGNORESKILL
}

Actor Research_Body_Ar_1_Tracker : Ammo {
	inventory.amount 1
	inventory.maxamount 25000
	ammo.backpackamount 0
	ammo.backpackmaxamount 25000
	+IGNORESKILL
}

Actor Research_Body_Im_1_Tracker : Ammo {
	inventory.amount 1
	inventory.maxamount 50
	ammo.backpackamount 0
	ammo.backpackmaxamount 50
	+IGNORESKILL
}

// ****************************
//		RESEARCH BONUSES
// ****************************

// this section is for bonuses that a research provides as soon as it is done

Actor ImpactProtection_1 : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.9
	damagefactor "ExplosivesFull", 0.9
	damagefactor "Explosives_Magic", 0.9
	damagefactor "Explosives_MagicFull", 0.9
}

Actor ImpactProtection_2 : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.75
	damagefactor "ExplosivesFull", 0.75
	damagefactor "Explosives_Magic", 0.75
	damagefactor "Explosives_MagicFull", 0.75
}

Actor ImpactProtection_3 : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.6
	damagefactor "ExplosivesFull", 0.6
	damagefactor "Explosives_Magic", 0.6
	damagefactor "Explosives_MagicFull", 0.6
}

Actor ImpactProtection_1_Cyborg : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.87
	damagefactor "ExplosivesFull", 0.87
	damagefactor "Explosives_Magic", 0.87
	damagefactor "Explosives_MagicFull", 0.87
}

Actor ImpactProtection_2_Cyborg : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.675
	damagefactor "ExplosivesFull", 0.675
	damagefactor "Explosives_Magic", 0.675
	damagefactor "Explosives_MagicFull", 0.675
}

Actor ImpactProtection_3_Cyborg : PowerProtection {
	powerup.duration 0x7FFFFFFF
	
	damagefactor "Explosives", 0.48
	damagefactor "ExplosivesFull", 0.48
	damagefactor "Explosives_Magic", 0.48
	damagefactor "Explosives_MagicFull", 0.48
}

// *******************
//		MODULES
// *******************

// Make a module if the research is intended to be droppable

Actor ResearchModule_MP : DnD_DroppedItem {
	Radius 20
	Height 24
	States {
		Spawn:
			TNT1 A 1
		Goto SpawnNormal
		Variant1:
			RC01 A 0 
		Goto SpawnInit
		Variant2:
			TNT1 A 0 A_SetScale(0.75, 0.75)
		VL:
			RC01 C 0
		Goto SpawnInit
		
		SpawnNormal:
			TNT1 A 0 A_Jump(128, "Variant1", "Variant2")
			RC01 B 0
		SpawnInit:
			"####" "#" 0 ACS_NamedExecuteAlways("DnD Remove Check Special", 0, mass, DND_SPECIAL_RESEARCH)
			"####" "#" 16
		SpawnLoop:
			"####" "#" 1 A_LookEx(LOF_NOSOUNDCHECK, 0, 28, 0, 360, "CheckPickup")
			"####" "#" 0 A_SpawnItemEx("ResearchFX", random(-32, 32), random(-32, 32), random(0, 8), 0, 0, random(2,8), 0, SXF_CLIENTSIDE, 0)
		Loop
		
		See:
		CheckPickup:
			"####" "#" 1 A_JumpIfCloser(32, "Pickup")
			"####" "#" 0 A_SpawnItemEx("ResearchFX", random(-32, 32), random(-32, 32), random(0, 8), 0, 0, random(2,8), 0, SXF_CLIENTSIDE, 0)
		goto SpawnLoop

		Pickup:
			"####" "#" 1 A_JumpIf(ACS_NamedExecuteWithResult("DnD Check Special Match", DND_SPECIAL_RESEARCH), "PickupSuccess")
			"####" "#" 0 A_SpawnItemEx("ResearchFX", random(-32, 32), random(-32, 32), random(0, 8), 0, 0, random(2,8), 0, SXF_CLIENTSIDE, 0)
		goto PickupFail

		PickupFail:
			"####" "#" 1
			"####" "#" 0 A_SpawnItemEx("ResearchFX", random(-32, 32), random(-32, 32), random(0, 8), 0, 0, random(2,8), 0, SXF_CLIENTSIDE, 0)
		goto SpawnLoop

		PickupSuccess:
//			"####" "#" 0 ACS_NamedExecuteAlways("DnD Message Logger", 0, 2, mass - 1, 1)
			"####" "#" 0 ACS_NamedExecuteAlways("DnD Give Research", 0, mass - 1)
		stop
	}
}

Actor ResearchSoundPlayer : DnD_Activator {
	States {
		Pickup:
			TNT1 A 0 A_PlaySound("items/research", 7)
			TNT1 A 0 A_SetBlend("80 80 80", 0.75, 10)
		Stop
	}
}