# npc_set_preference

!! npc_code = 'A***', 'B***', 'C***', etc.

!!	Full reset of npc preferences:
!!		gs 'npc_set_preference', 'reset', npc_code
!!
!!	Add a preference to an npc:
!!		gs 'npc_set_preference', $npc_code, $trait, [$amount/amount]
!!		npc_code = 'A12', 'A51', 'B13', 'C1', etc
!!		trait: = 'body_strong', 'cum_face', 'body_tits_big', 'body_ass_bubble', etc.
!!
!!		you can either use a string or number for amount:
!!		$amount = 'hate', 'dislike', 'neutral', 'like', 'love'
!!		amount is the change in appearance that this preference causes.
!!
!!		examples:
!!			gs 'npc_set_preference', 'A12', 'body_tits_big', 'like'
!!			gs 'npc_set_preference', 'B1', 'body_bmi_overweight', -50



if $ARGS[0] = 'reset':
	$npc_preferences[$ARGS[1]] = ''
end


!! $ARGS[0] = 'A***', 'B***', 'C***', etc.
if isnum(mid($ARGS[0], 2)):
	
	!!Dynamically create the $npc_pref_traits and npc_trait_values arrays
	dynamic $npc_preferences[$ARGS[0]]
	dynamic $npc_pref_values[$ARGS[0]]
	
	!! Example of these created arrays.
	!!$npc_pref_traits: npc_pref_traits[i] = 'strong'
	!!npc_trait_values: npc_trait_values['strong'] = -15

	if $ARGS[2] = '':
		temp_set_preference_trait_value = ARGS[2]
	else
		!! Translate 'hate, dislike, etc. into a number and store it.'
		temp_set_preference_trait_value = func('npc_set_preference', 'get_value', $ARGS[1], $ARGS[2])
	end

	!! This block of code is here to find the index of the preferences.
	skip_check_preferences_loop = 0
	:check_preference_loop_start

	!! Escape the preference loops if we found the index of the preferences
	if skip_check_preferences_loop = 0:
		if arrsize('$npc_pref_traits') > 0:
			preference_loop_index = 0

			:check_preferences_loop
				if $npc_pref_traits[preference_loop_index] = $ARGS[1]:
					skip_check_preferences_loop = 1
					jump 'check_preference_loop_start'
				end
				preference_loop_index += 1
			if preference_loop_index < arrsize('$npc_pref_traits'): jump 'check_preferences_loop'

		end
	end

	if temp_set_preference_trait_value ! 0:
		if arrsize('$npc_pref_traits') = 0:
			!!replace(..., '	', '') is there to remove the tabs from the string.
			$npc_preferences[$ARGS[0]] = replace({killvar '$npc_pref_traits'
				$npc_pref_traits[] = } + "'<<$ARGS[1]>>'" + {
			}, '	', '')

			$npc_pref_values[$ARGS[0]] = replace({killvar 'npc_trait_values'
				npc_trait_values} + "['<<$ARGS[1]>>'] = <<temp_set_preference_trait_value>>" + {
			}, '	', '')

		else
			if preference_loop_index < arrsize('$npc_pref_traits'):
				!!The npc already has a preference for the trait.
				!!We overwrite the trait and then escape the preference_loop
				npc_trait_values[$ARGS[1]] = temp_set_preference_trait_value

				!!Rebuild the $npc_pref....[$ARGS[0]] strings from the grounds up
				gs 'npc_set_preference', 'rebuild_preferences', $ARGS[0]

			else
				!!We have checked that the npc has no preference for the trait.
				!!We add the preference to the npc.
				$npc_preferences[$ARGS[0]] += replace({$npc_pref_traits[] = } + "'<<$ARGS[1]>>'" + {
				}, '	', '')

				$npc_pref_values[$ARGS[0]] += replace({npc_trait_values} + "['<<$ARGS[1]>>'] = <<temp_set_preference_trait_value>>" + {
				}, '	', '')
			end
		end

	else
		!! The trait exists and we are setting it to 0. Best just remove it entirely
		if temp_preference_loop_index < arrsize('$npc_pref_traits'):
			killvar '$npc_pref_traits', temp_preference_loop_index
			gs 'shortgs', 'remove_array_element', 'npc_trait_values', $ARGS[1]

			!!Rebuild the $npc_pref....[$ARGS[0]] strings from the grounds up
			gs 'npc_set_preference', 'rebuild_preferences', $ARGS[0]
		end
	end


	killvar '$npc_pref_traits'
	killvar 'npc_trait_values'

	killvar 'preference_loop_index'

	killvar 'temp_set_preference_trait_value'
end



!! Called as gs 'npc_set_preference', 'rebuild_preferences', $npc_code
if $ARGS[0] = 'rebuild_preferences':
	!!Rebuild the $npc_pref....[$ARGS[0]] strings from the grounds up
	$temp_npc_pref_traits = {killvar '$npc_pref_traits'
	}
	$temp_npc_trait_values = {killvar 'npc_trait_values'
	}

	!!Loop over every preference and add it to the $npc_pref....[$ARGS[0]] strings.
	rebuild_preferences_index = 0
	:rebuild_preferences_loop
		$temp_npc_pref_traits += {$npc_pref_traits[] = } + "'<<$npc_pref_traits[rebuild_preferences_index]>>'" + {
		}
		$temp_npc_trait_values += {npc_trait_values} + "['<<$npc_pref_traits[rebuild_preferences_index]>>'] = <<npc_trait_values[rebuild_preferences_index]>>" + {
		}

		rebuild_preferences_index += 1
	if rebuild_preferences_index < arrsize('$npc_pref_traits'): jump 'rebuild_preferences_loop'


	!!Overwrite the $npc_pref....[$ARGS[0]] strings with the rebuild string.
	$npc_preferences[$ARGS[0]] = replace($temp_npc_pref_traits,    '	', '')
	$npc_pref_values[$ARGS[0]] = replace($temp_npc_trait_values,   '	', '')

	killvar '$temp_npc_pref_traits'
	killvar '$temp_npc_trait_values'
	killvar 'rebuild_preferences_index'
end


!! Called as gs 'npc_set_preference', 'remove_prefence', $npc_code, $pref_trait
if $ARGS[0] = 'remove_preference':
	if arrsize('$npc_pref_traits') > 0:
		!! Check the position of the preference in the preference array.
		temp_set_preferences_trait_position = arrpos('$npc_pref_traits', $ARGS[2])
		
		!! If the preference exists:
		if temp_set_preferences_trait_position ! -1:
			!! Remove the preference from the array.
			killvar '$npc_pref_traits', temp_set_preferences_trait_position
			gs 'shortgs', 'remove_array_element', 'npc_trait_values', $ARGS[2]
			
			!! Then rebuild the dynamic string.
			gs 'npc_set_preference', 'rebuild_preferences', $ARGS[1]
		end

		killvar 'temp_set_preferences_trait_position'
	end
end


!!====================================!!
!!                                    !!
!!        Calculate pref_value        !!
!!                                    !!
!!====================================!!


!!	gs 'npc_set_preference', 'get_value', $PREFERENCE, $VALUE
!!		$PREFERENCE: body_fit, clothes_style_bimbo, etc.
!!		$VALUE: 'love', 'like', 'neutral', 'dislike', or 'hate'

if $ARGS[0] = 'get_value':
	temp_pref_values['love']    = 10
	temp_pref_values['like']    = 3
	temp_pref_values['neutral'] = 0
	temp_pref_values['dislike'] = -3
	temp_pref_values['hate']    = -10

	if $ARGS[1] = 'body_bmi_starving':
		temp_pref_values['love']    = 60
		temp_pref_values['like']    = 40
		temp_pref_values['dislike'] = -5
		temp_pref_values['hate']    = -10

	elseif $ARGS[1] = 'body_bmi_underweight':
		temp_pref_values['love']    = 10
		temp_pref_values['like']    = 5
		temp_pref_values['dislike'] = -25
		temp_pref_values['hate']    = -35

	elseif $ARGS[1] = 'body_bmi_normal':
		temp_pref_values['love']    = 5
		temp_pref_values['like']    = 2
		temp_pref_values['dislike'] = -50
		temp_pref_values['hate']    = -70

	elseif $ARGS[1] = 'body_bmi_overweight':
		temp_pref_values['love']    = 10
		temp_pref_values['like']    = 5
		temp_pref_values['dislike'] = -25
		temp_pref_values['hate']    = -35

	elseif $ARGS[1] = 'body_bmi_obese':
		temp_pref_values['love']    = 60
		temp_pref_values['like']    = 40
		temp_pref_values['dislike'] = -5
		temp_pref_values['hate']    = -10

	elseif $ARGS[1] = 'body_skin_bad':
		temp_pref_values['love']    = 2
		temp_pref_values['like']    = 1
		temp_pref_values['dislike'] = -1
		temp_pref_values['hate']    = -2
	
	elseif $ARGS[1] = 'body_skin_normal':
		temp_pref_values['love']    = 2
		temp_pref_values['like']    = 1
		temp_pref_values['dislike'] = -1
		temp_pref_values['hate']    = -2
	
	elseif $ARGS[1] = 'body_skin_good':
		temp_pref_values['love']    = 2
		temp_pref_values['like']    = 1
		temp_pref_values['dislike'] = -1
		temp_pref_values['hate']    = -2
	end

	if $ARGS[2] ! '':
		result = temp_pref_values[$ARGS[2]]
	else
		if ARGS[2] = temp_pref_values['neutral']:
			$result = 'neutral'
		elseif ARGS[2] < (temp_pref_values['hate'] + temp_pref_values['dislike']) / 2:
			$result = 'hate'
		elseif ARGS[2] > (temp_pref_values['love'] + temp_pref_values['like']) / 2:
			$result = 'love'
		elseif ARGS[2] < (temp_pref_values['dislike'] + temp_pref_values['neutral']) / 2:
			$result = 'dislike'
		elseif ARGS[2] > (temp_pref_values['like'] + temp_pref_values['neutral']) / 2:
			$result = 'like'
		else
			$result = 'neutral'
		end
	end

	killvar 'temp_pref_values'
end



!!		Preferences:
!!		
!!		body:
!!			ass:
!!				body_ass_flat
!!				body_ass_average
!!				body_ass_big
!!				body_ass_heart
!!				body_ass_bubble
!!			bmi:
!!				body_bmi_starving
!!				body_bmi_underweight
!!				body_bmi_normal
!!				body_bmi_overweight
!!				body_bmi_obese
!!			eyes:
!!				body_eyes_brown
!!				body_eyes_grey
!!				body_eyes_green
!!				body_eyes_blue
!!			lips:
!!				body_lips_thin
!!				body_lips_normal
!!				body_lips_plump
!!				body_lips_big
!!				body_lips_pillowy
!!			skin:
!!				body_skin_bad
!!				body_skin_normal
!!				body_skin_good
!!			strength:
!!				body_strength_weak
!!				body_strenght_normal
!!				body_strenght_athletic
!!				body_strenght_strong
!!				body_strenght_manly
!!			sweat:
!!				body_sweat_none
!!				body_sweat_sweaty
!!				body_sweat_stinky
!!			tits:
!!				body_tits_small
!!				body_tits_average
!!				body_tits_big
!!				body_tits_huge
!!			body_fit
!!			body_pregnant
!!			body_tan
!!			body_tan_not
!!		
!!		clothes:
!!			exposed:
!!				clothes_exposed_ass
!!				clothes_exposed_bra
!!				clothes_exposed_panties
!!				clothes_exposed_pussy
!!				clothes_exposed_tits
!!			skirt:
!!				clothes_skirt_long
!!				clothes_skirt_normal
!!				clothes_skirt_short
!!			style:
!!				clothes_style_bimbo
!!				clothes_style_goth
!!				clothes_style_punk
!!			clothes_thin
!!		
!!		cosmetics:
!!			cosmetics_deodorant
!!			cosmetics_makeup
!!			cosmetics_piercing
!!			cosmetics_tattoo
!!		
!!		cum:
!!			cum_clothes
!!			cum_face
!!		
!!		hair:
!!			color:
!!				hair_color_black
!!				hair_color_brown
!!				hair_color_red
!!				hair_color_blonde
!!				hair_color_dyed
!!			length:
!!				hair_length_veryshort
!!				hair_length_short
!!				hair_length_chin
!!				hair_length_shoulder
!!				hair_length_bra
!!				hair_length_long
!!			pubes:
!!				hair_pubes_shaven
!!				hair_pubes_grown
!!				hair_pubes_styled
!!			hair_leg
!!			hair_leg_not
!!			hair_curly
!!			hair_straight



--- npc_set_preference ---------------------------------