# npccleanc

!! {This code should be called to purge a specific NPC. It expects an ARGS[0] of the code of the C array.}
$tempcclean = $ARGS[0]

if mid($tempcclean, 1, 1) = 'C' and npc_firstname['$tempcclean'] > 0:
    !! {create arrays to loop through}
    ! {array for strings}
    $tmpStrArr[0] = 'npc_firstname'
    $tmpStrArr[] = 'npc_nickname'
    $tmpStrArr[] = 'npc_lastname'
    $tmpStrArr[] = 'npc_usedname'
    $tmpStrArr[] = 'npc_notes'
    $tmpStrArr[] = 'npc_firstpart'
    $tmpStrArr[] = 'npc_lastpart'
    $tmpStrArr[] = 'npc_kidpater'
    $tmpStrArr[] = 'npc_thdick'
    $tmpStrArr[] = 'npc_dad'
    $tmpStrArr[] = 'npc_mom'
    $tmpStrArr[] = 'npc_pic'
    $tmpStrArr[] = 'npc_PersType'
    $tmpStrArr[] = 'npc_dna'
    ! {array for ints}
    $tmpIntArr[0] = 'npc_dob'
    $tmpIntArr[] = 'npc_vital'
    $tmpIntArr[] = 'npc_stren'
    $tmpIntArr[] = 'npc_intel'
    $tmpIntArr[] = 'npc_agil'
    $tmpIntArr[] = 'npc_sprt'
    $tmpIntArr[] = 'npc_magik'
    $tmpIntArr[] = 'npc_drunk'
    $tmpIntArr[] = 'npc_pantys'
    $tmpIntArr[] = 'npc_cyc'
    $tmpIntArr[] = 'npc_fert'
    $tmpIntArr[] = 'npc_gender'
    $tmpIntArr[] = 'npc_dick'
    $tmpIntArr[] = 'npc_sexskill'
    $tmpIntArr[] = 'npc_spermpot'
    $tmpIntArr[] = 'npc_vag'
    $tmpIntArr[] = 'npc_ass'
    $tmpIntArr[] = 'npc_hymen'
    $tmpIntArr[] = 'npc_horny'
    $tmpIntArr[] = 'npc_Pavrep'
    $tmpIntArr[] = 'npc_Godrep'
    $tmpIntArr[] = 'npc_apprnc'
    $tmpIntArr[] = 'npc_lipbalm'
    $tmpIntArr[] = 'npc_makeup'
    $tmpIntArr[] = 'npc_sweat'
    $tmpIntArr[] = 'npc_dye'
    $tmpIntArr[] = 'npc_hairbsh'
    $tmpIntArr[] = 'npc_skin'
    $tmpIntArr[] = 'npc_bodyhair'
    $tmpIntArr[] = 'npc_breath'
    $tmpIntArr[] = 'npc_hipcurv'
    $tmpIntArr[] = 'npc_hgt'
    $tmpIntArr[] = 'npc_bust'
    $tmpIntArr[] = 'npc_nips'
    $tmpIntArr[] = 'npc_fat'
    $tmpIntArr[] = 'npc_haircol'
    $tmpIntArr[] = 'npc_tan'
    $tmpIntArr[] = 'npc_lip'
    $tmpIntArr[] = 'npc_lashes'
    $tmpIntArr[] = 'npc_eyesize'
    $tmpIntArr[] = 'npc_eyecol'
    $tmpIntArr[] = 'npc_dom'
    $tmpIntArr[] = 'npc_sub'
    $tmpIntArr[] = 'npc_QW'
    $tmpIntArr[] = 'npc_rel'
    $tmpIntArr[] = 'npc_love'
    $tmpIntArr[] = 'npc_job'
    $tmpIntArr[] = 'npc_cloc'
    $tmpIntArr[] = 'npc_herpes'
    $tmpIntArr[] = 'npc_syth'
    $tmpIntArr[] = 'npc_gon'
    $tmpIntArr[] = 'npc_thrush'
    $tmpIntArr[] = 'npc_chem'
    $tmpIntArr[] = 'npc_clothpref'

    ! {loop through the arrays to kill entries}
    tmpArrIndex = 0
    :cleanupstrloop
    if tmpArrIndex < arrsize('$tmpStrArr'):
        tmpNpcIndex = arrpos(('<<$tmpStrArr[tmpArrIndex]>>'), val('<<mid($tempcclean, 2)>>'))
        if tmpNpcIndex >= 0:
            killvar '<<$tmpStrArr[tmpArrIndex]>>', tmpNpcIndex
        end
        tmpArrIndex += 1
        jump 'cleanupstrloop'
    end
    tmpArrIndex = 0
    :cleanupintloop
    if tmpArrIndex < arrsize('$tmpIntArr'):
        tmpNpcIndex = arrpos(('$<<$tmpIntArr[tmpArrIndex]>>'), '<<mid($tempcclean, 2)>>')
        if tmpNpcIndex >= 0:
            killvar ('$<<$tmpIntArr[tmpArrIndex]>>'), tmpNpcIndex
        end
        tmpArrIndex += 1
        jump 'cleanupintloop'
    end

    ! {cleanup}
    killvar 'tmpArrIndex'
    killvar 'tmpNpcIndex'
    killvar 'tmpStrArr'
    killvar 'tmpIntArr'
else
	! {legacy code in case there is no corresponding index: just sets values to default}
	$npc_firstname[$tempcclean] = ''
	$npc_nickname[$tempcclean] = ''
	$npc_lastname[$tempcclean] = ''
	$npc_usedname[$tempcclean] = ''
	$npc_notes[$tempcclean] = ''
	npc_dob[$tempcclean] = 0
	npc_vital[$tempcclean] = 0
	npc_stren[$tempcclean] = 0
	npc_intel[$tempcclean] = 0
	npc_agil[$tempcclean] = 0
	npc_sprt[$tempcclean] = 0
	npc_magik[$tempcclean] = 0
	npc_drunk[$tempcclean] = 0
	npc_pantys[$tempcclean] = 0
	npc_cyc[$tempcclean] = 0
	npc_fert[$tempcclean] = 0
	$npc_firstpart[$tempcclean] = ''
	$npc_lastpart[$tempcclean] = ''
	$npc_kidpater[$tempcclean] = ''
	npc_gender[$tempcclean] = 0
	$npc_thdick[$tempcclean] = ''
	npc_dick[$tempcclean] = 0
	npc_sexskill[$tempcclean] = 0
	npc_spermpot[$tempcclean] = 0
	npc_vag[$tempcclean] = 0
	npc_ass[$tempcclean] = 0
	npc_hymen[$tempcclean] = 0
	npc_horny[$tempcclean] = 0
	npc_Pavrep[$tempcclean] = 0
	npc_Godrep[$tempcclean] = 0
	npc_apprnc[$tempcclean] = 0
	npc_lipbalm[$tempcclean] = 0
	npc_makeup[$tempcclean] = 0
	npc_sweat[$tempcclean] = 0
	npc_dye[$tempcclean] = 0
	npc_hairbsh[$tempcclean] = 0
	npc_skin[$tempcclean] = 0
	npc_bodyhair[$tempcclean] = 0
	npc_breath[$tempcclean] = 0
	npc_hipcurv[$tempcclean] = 0
	npc_hgt[$tempcclean] = 0
	npc_bust[$tempcclean] = 0
	npc_nips[$tempcclean] = 0
	npc_fat[$tempcclean] = 0
	npc_haircol[$tempcclean] = 0
	npc_tan[$tempcclean] = 0
	npc_lip[$tempcclean] = 0
	npc_lashes[$tempcclean] = 0
	npc_eyesize[$tempcclean] = 0
	npc_eyecol[$tempcclean] = 0
	npc_dom[$tempcclean] = 0
	npc_sub[$tempcclean] = 0
	npc_QW[$tempcclean] = 0
	npc_rel[$tempcclean] = 0
	npc_love[$tempcclean] = 0
	npc_job[$tempcclean] = 0
	npc_cloc[$tempcclean] = 0
	$npc_dad[$tempcclean] = ''
	$npc_mom[$tempcclean] = ''
	$npc_pic[$tempcclean] = ''
	npc_herpes[$tempcclean] = 0
	npc_syth[$tempcclean] = 0
	npc_gon[$tempcclean] = 0
	npc_thrush[$tempcclean] = 0
	npc_chem[$tempcclean] = 0
	npc_clothpref[$tempcclean] = 0
	$npc_PersType[$tempcclean] = ''
	$npc_dna[$tempcclean] = ''    
end

i = arrsize('$cemptyarray')
$cemptyarray[i] = $tempcclean

:clean_sanity_loop
i = arrsize('$cemptyarray') 
If i > 1 and $cemptyarray[0] = $cemptyarray[i]: killvar '$cemptyarray', i & jump 'clean_sanity_loop'

killvar '$tempcclean'

--- npccleanc ---------------------------------

