Scriptname CLAPAddLLScript extends ObjectReference

LeveledItem Property CLAPFlyersList80 Auto Const

LeveledItem Property Container_Loot_Trashbin Auto Const

LeveledItem Property Container_Loot_Trashcan Auto Const

LeveledItem Property Container_Loot_Mailbox Auto Const

LeveledItem Property BCLABibleList20 Auto Const

LeveledItem Property LLI_Vendor_Items_Small_Basic Auto Const

GlobalVariable Property ClapFlyerRead Auto Const

GlobalVariable Property CLAPRaidersAttackChance Auto Const

GlobalVariable Property CLAPVersion Auto Const

GlobalVariable Property BCLAMagazineRead Auto Const

Float Property BCLAMagValue Auto Const

float cversion

function installclap()
	float r = ClapFlyerRead.GetValue()
	if r == 0.0
		Container_Loot_Trashbin.AddForm(CLAPFlyersList80,1,1)
		Container_Loot_Trashcan.AddForm(CLAPFlyersList80,1,1)
		Container_Loot_Mailbox.AddForm(CLAPFlyersList80,1,1)
		Container_Loot_Mailbox.AddForm(BCLABibleList20,1,1)
		LLI_Vendor_Items_Small_Basic.AddForm(BCLABibleList20,1,1)
		ClapFlyerRead.SetValue(1.0)
	endif
endfunction

function maintenance()
	float ac = CLAPRaidersAttackChance.GetValue()
	if ac > 10.0
		CLAPRaidersAttackChance.SetValue(10.0)
		debug.notification("Clapper Attack Chance set to 10 percent")
	endif
endfunction	

function BCLAGlobalSet()
	if BCLAMagValue >= 1.0 && BCLAMagazineRead.GetValue() < BCLAMagValue
		BCLAMagazineRead.SetValue(BCLAMagValue)
	endif
endfunction	

Event OnRead()
	; First installation
	installclap()
	; Updates and maintenance
	cversion = CLAPVersion.GetValue()
	if cversion < 1.2
		cversion = 1.2
		CLAPVersion.SetValue(cversion)
		maintenance()
		debug.notification("CLAP updated to version " + cversion)
	endif
	; run whenever item is read
	BCLAGlobalSet()
EndEvent


