code:
# #dynamic

$guild_contract_loli_magic = {
	! this is for the Old Man libido challenge and runs when a guild contract is accepted (started)
	if no_loli ! 1 and is_perv > 1 and stock['age'] = CONST_INT['loli_age'] and stock['beauty'] > 2:
		if is_perv = 3 and loli_magic < 2:
			msg '  Oddly, as you take the girl’s little hand to lead her home you feel a stirring in your breeches. As you have not had a proper erection in many years, this is rather strange. Is it some sort of Eternal Rome magic?'
			is_perv = 2
			loli_magic += 1
			master_perv_rate += 7
			if master_excitement_rate < 16: master_excitement_rate = 16 & master_excitement = 1
			master_mood_rate += 16
		elseif is_perv = 2 and loli_magic = 2 and assistant_state > CONST_INT['no_slave'] and assistant['age'] = CONST_INT['loli_age'] and assistant['beauty'] > 2:
			msg '  As you take the girl’s<<$little_txt>> hand to lead her home, just imagining what you can do with this new slave and your adorable assistant has you ignited!'
			is_perv = 1
			master_perv_rate += 14
			master_libido_rate = max(master_libido_rate, master_libido_rate_cap[1])
			if master_excitement_rate < 32: master_excitement_rate = 32 & master_excitement = 2
			master_mood_rate += 32
		end
	end
}

$scroll_heroes = {
	if hero_choice < 12:
		hero_choice += 1
	else
		hero_choice = 1
	end
	gt $curloc
}

$scroll_heroes_back = {
	if hero_choice > 1:
		hero_choice -= 1
	else
		hero_choice = 12
	end
	gt $curloc
}

$scroll_ava = {
	if hero_choice < 12:
		hero_choice += 1
	else
		hero_choice = 1
	end
	gt $curloc
}

$scroll_ava_back = {
	if hero_choice > 1:
		hero_choice -= 1
	else
		hero_choice = 12
	end
	gt $curloc
}

$name_and_start = {
	$estate = 'slum_house'
	$starting_area = 'The Slums'
	!$a = input ('Give your character a name. Please try to keep this shorter than 14 characters.')
	!if $a !'': $master_name = $a
	gt 'start_game'
}

$name_type = {
	$a = input ('Give your character a name. Please try to keep this shorter than 14 characters.')
	if $a !'': $master_name = $a
	gt $curloc
}

$game_difficulty_decrease = {
	if game_difficulty > 0:
		game_difficulty -= 1
		if game_difficulty = 0:
			! easy
			hero_points += 2940 &! 2940 is required to max everything
			sparks += 4000
			if sparks > 10000:
				hero_points += (sparks - 10000)/10
				sparks = 10000
			end
			difficulty_setting = 1 &! easy obedience difficulty
			get_initial_slave = 1 &! enable patrician start mode
		elseif game_difficulty = 1:
			! normal
			hero_points += 250
			sparks += 5600
			if sparks > 7500:
				hero_points += (sparks - 7500)/10
				sparks = 7500
			end
			difficulty_setting = 0 &! classic obedience difficulty
			get_initial_slave = 0 &! disable patrician start mode
		end
	end
	gt $curloc
}

$game_difficulty_increase = {
	if game_difficulty < 2:
		game_difficulty += 1
		if game_difficulty = 1:
			! normal
			hero_points -= 2940 &! difference in points from Easy to Normal
			sparks -= 4000 &! difference in sparks from Easy to Normal
			if sparks > 7500:
				hero_points += (sparks - 7500)/10
				sparks = 7500
			end
			difficulty_setting = 0 &! classic obedience difficulty
			get_initial_slave = 0 &! disable patrician start mode
		elseif game_difficulty = 2:
			! extreme
			if cheat_a ! 0 or cheat_b ! 0 or cheat_c ! 0 or cheat_d ! 0 or cheat_h ! 0 or cheat_i ! 0 or _
				cheat_j ! 0 or cheat_k ! 0 or cheat_l ! 0 or cheat_all ! 0 or cheat_all_basic ! 0 or _
				cheat_all_low ! 0 or cheat_all_max ! 0 or isabella_get ! 0:
				! e,f,g limit slave generation to selected age - no reset for these
				gs 'init_custom_game' &! full reset to disable cheats for extreme difficulty - ImperatorAugustus
			end
			hero_points -= 250 &! difference in points from Normal to Extreme
			sparks -= 5600 &! difference in sparks from Normal to Extreme
			if sparks > 400:
				hero_points += (sparks - 400)/10
				sparks = 400
			end
			difficulty_setting = 2 &! hardcore obedience difficulty
			get_initial_slave = 0 &! disable patrician start mode
		end
	end
	gt $curloc
}

$sparks_decrease = {
	if sparks > 200:
		sparks -= 100
		hero_points += 10
	end
	gt $curloc
}

$sparks_increase = {
	if sparks < iif(game_difficulty = 0, 10000, iif(game_difficulty = 2, 400, 8000)):
		sparks += 100
		hero_points -= 10
	end
	gt $curloc
}

$go_forward = {
	unsel
	txt_count = arrsize('$text') - 1
	if txt < txt_count:
		txt += 1
	else
		delobj '@'
		if $msg_txt ! '' and txt_count = txt:
			msg '<<$msg_txt>>'
			$msg_txt = ''
		end
		if exam_in_progress = 1:
			gt 'demo_menu_form'
		elseif is_home ! 1:
			gt 'city_menu_form'
		else
			gt 'menu_form'
		end
	end
	gt $curloc
}

$dyn_meat_evaluation = {
	base_meat_gain = (dynslave['fat'] + 2)
	if dynslave['age'] ! CONST_INT['loli_age']: base_meat_gain *= 2
	mince_gain = dynslave['fat']
	if dynslave['boobs'] > 0: mince_gain *= dynslave['boobs']
	mince_bonus = 0
	meat_max = 1 + dynslave['stamina']
	if dynslave['age'] ! CONST_INT['loli_age']: meat_max *= 2
	if base_meat_gain > meat_max:
		meat_gain = meat_max
		mince_bonus = base_meat_gain - meat_max
	else
		meat_gain = base_meat_gain
	end
	mince_gain += mince_bonus
	if dynslave['age'] = CONST_INT['loli_age'] or (dynslave['age'] = CONST_INT['young_age'] and dynslave['virginity'] = 0):
		! was virginity = 1, error when the butcher gave virgin meat when hymen is restored
		virgin_meat_gain = meat_gain
		meat_gain = 0
	else
		virgin_meat_gain = 0
	end
	meat_price = mince_gain + meat_gain*2 + virgin_meat_gain*4
}

$get_meat = {
	if fridge_space > 0:
		if fridge_space >= virgin_meat_gain:
			fridge["virgin_meat"] += virgin_meat_gain
		else
			fridge["virgin_meat"] += fridge_space
		end
	end
	if fridge_space > 0:
		if fridge_space >= meat_gain:
			fridge["meat"] += meat_gain
		else
			fridge["meat"] += fridge_space
		end
	end
	if fridge_space > 0:
		if fridge_space >= mince_gain:
			fridge["mince"] += mince_gain
		else
			fridge["mince"] += fridge_space
		end
	end
}

$get_fridge_space = {
	fridge_items = fridge["vegetables"] + fridge["flower"] + fridge["spice"] + fridge["cheese"] + fridge["eggs"] + fridge["milk"] + fridge["cream"] + fridge["mince"] + fridge["meat"] + fridge["virgin_meat"]
	fridge_space = estate_size[$estate] - fridge_items
}

$get_lab_space = {
	lab_items = lab_store["slime"] + lab_store["kanabis"] + lab_store["koffe"] + lab_store["meth"] + lab_store["opium"] + вакхический_нектар + тонизируюзщий_эликсир + целительный_бальзам + афродизиак + мощный_афодизиак + приворотное_зелье + вода_леты
	lab_space = estate_size[$estate] - lab_items
}

$master_pass_out = {
	if master_str_rate < 0: dynamic $death, 'The work so depleted your health that you became seriously ill and had to withdraw from your goal. You will never become a real slave master…'
	if master_energy <= -5: is_home = 1 & gt 'next_day' &! is_home = 1 to bypass menu_form ESC intercept
}

!Slave pass out - Overhauled - crushboss
$slave_pass_out = {
	if slave_state > CONST_INT['no_slave']:
		if slave_state = CONST_INT['slave_exist']:
			if slave['energy'] <= -5:
				msg 'Your slave fainted due to extreme exhaustion.'
				slave_state = CONST_INT['slave_faint']
			elseif slave['stamina'] = 0:
				msg 'Your slave fainted due to having no stamina.'
				slave_state = CONST_INT['slave_faint']
			elseif slave['stamina'] = 1 and slave_rate['stamina'] <= 0:
				if slave['nearly_fainted'] = 0: msg 'Your slave nearly fainted due to a lack of stamina.'
				slave['nearly_fainted'] = 1
			end
		end
		if cheat_no_starve = 0 and max(slave['stamina'], slave['fat']) = 0 and max(slave_rate['stamina'], slave_rate['fat']) <= indep_atr_min_threshold[0]:
			dynamic $replace($dyn_meat_evaluation, 'dyn'+'slave', 'slave')
			master_moodlet['neg_slave_starved'] = 3
			if exam_in_progress ! 1: msg 'Your slave died from starvation. You sold her body to the butcher for <<meat_price>> sparks.'
			sparks += meat_price
			dynamic $clear_slave_instance, 'slave'
		end
	end
}

!Assistant pass out - Added for assistant - crushboss
$assistant_pass_out = {
	if assistant_state > CONST_INT['no_slave']:
		if assistant_state = CONST_INT['slave_exist']:
			if assistant['energy'] <= -5:
				msg 'Your assistant fainted due to extreme exhaustion.'
				assistant_state = CONST_INT['slave_faint']
			elseif assistant['stamina'] = 0:
				msg 'Your assistant fainted due to having no stamina.'
				assistant_state = CONST_INT['slave_faint']
			elseif assistant['stamina'] = 1 and assistant_rate['stamina'] <= 0:
				if assistant['nearly_fainted'] = 0: msg 'Your assistant nearly fainted due to a lack of stamina.'
				assistant['nearly_fainted'] = 1
			end
		end
		if cheat_no_starve = 0 and max(assistant['stamina'], assistant['fat']) = 0 and max(assistant_rate['stamina'], assistant_rate['fat']) <= indep_atr_min_threshold[0]:
			dynamic $replace($dyn_meat_evaluation, 'dyn'+'slave', 'assistant')
			master_moodlet['neg_slave_starved'] = 3
			if exam_in_progress ! 1: msg 'Your assistant died from starvation. You sold her body to the butcher for <<meat_price>> sparks.'
			sparks += meat_price
			dynamic $clear_slave_instance, 'assistant'
		end
	end
}

$cow_pass_out = {
	if cow_state > CONST_INT['no_slave']:
		if cow_state = CONST_INT['slave_exist']:
			if cow['energy'] <= -5:
				msg 'Your cow fainted due to extreme exhaustion.'
				cow_state = CONST_INT['slave_faint']
			elseif cow['stamina'] = 0:
				msg 'Your cow fainted due to having no stamina.'
				cow_state = CONST_INT['slave_faint']
			elseif cow['stamina'] = 1 and cow_rate['stamina'] <= 0:
				if cow['nearly_fainted'] = 0: msg 'Your cow nearly fainted due to a lack of stamina.'
				cow['nearly_fainted'] = 1
			end
		end
		if cheat_no_starve = 0 and max(cow['stamina'], cow['fat']) = 0 and max(cow_rate['stamina'], cow_rate['fat']) <= indep_atr_min_threshold[0]:
			dynamic $replace($dyn_meat_evaluation, 'dyn'+'slave', 'cow')
			master_moodlet['neg_slave_starved'] = 3
			if exam_in_progress ! 1: msg 'Your cow died from starvation. You sold her body to the butcher for <<meat_price>> sparks.'
			sparks += meat_price
			dynamic $clear_slave_instance, 'cow'
		end
	end
}

$prisoner_pass_out = {
	if prisoner_state > CONST_INT['no_slave']:
		if prisoner_state = CONST_INT['slave_exist']:
			if prisoner['energy'] <= -5:
				msg 'Your prisoner fainted due to extreme exhaustion.'
				$prisoner_info_text = ''
				prisoner_state = CONST_INT['slave_faint']
			elseif prisoner['stamina'] = 0:
				msg 'Your prisoner fainted due to having no stamina.'
				$prisoner_info_text = ''
				prisoner_state = CONST_INT['slave_faint']
			elseif prisoner['stamina'] = 1 and prisoner_rate['stamina'] <= 0:
				if prisoner['nearly_fainted'] = 0: msg 'Your prisoner nearly fainted due to a lack of stamina.'
				prisoner['nearly_fainted'] = 1
			end
		end
		if cheat_no_starve = 0 and max(prisoner['stamina'], prisoner['fat']) = 0 and max(prisoner_rate['stamina'], prisoner_rate['fat']) <= indep_atr_min_threshold[0]:
			$prisoner_info_text = ''
			$tmp = 'Your prisoner died from starvation, forgotten in a dungeon cage. You sold her body to the butcher for <<meat_price>> sparks.'
			if prisoner['prison_food_type'] = 3: $tmp = 'Your prisoner has died from malnutrition. In her weakened state, a diet of nothing but cookies was not enough to sustain her.'
			msg $tmp
			dynamic $replace($dyn_meat_evaluation, 'dyn'+'slave', 'prisoner')
			sparks += meat_price
			dynamic $clear_slave_instance, 'prisoner'
		end
	end
}

!if slave died in combat against master
$slave_killed = {
	dynamic $replace($dyn_meat_evaluation, 'dyn'+'slave', 'slave')
	master_moodlet['neg_slave_killed'] = 3
	if exam_in_progress ! 1: msg 'You killed your slave in battle. You sold her body to the butcher for <<meat_price>> sparks.'
	sparks += meat_price
	dynamic $clear_slave_instance, 'slave'
}

$toolsequipped = {
	whipequipped = 0
	lashequipped = 0

	!if $master_back_wpn = 'кнут':   whipequipped = 1 &! cannot go on back
	if $master_left_wpn = 'кнут':   whipequipped = 1
	if $master_right_wpn = 'кнут':  whipequipped = 1
	!if $master_arm_wpn = 'кнут':    whipequipped = 1 &! cannot go in sleeve
	!if $master_leg_wpn = 'кнут':    whipequipped = 1 &! cannot go in boot

	!if $master_back_wpn = 'нагайка':  lashequipped = 1 &! cannot go on back
	if $master_left_wpn = 'нагайка':  lashequipped = 1
	if $master_right_wpn = 'нагайка': lashequipped = 1
	if $master_arm_wpn = 'нагайка':   lashequipped = 1
	if $master_leg_wpn = 'нагайка':   lashequipped = 1
}

!Repulse Check - crushboss

$dyn_sex_acceptance = {
	! sub-calculation for $dyn_repulse_check, called from interaction, interaction_city, interaction_result
	! no effect unless stimulating flag is enabled (expected to be enabled for any interactions that set erotic_stimulation in $special_part)
	! sets interaction_*['sex_acceptance'], to be interpreted as a bonus/penalty to obedience, uncapped, values < 0 indicate reluctance
	! expects to be called with dynamic $replace($dyn_sex_acceptance, 'dyn'+'slave', 'a slave instance variable')
	interaction_dynslave['sex_acceptance'] = 0
	if dynslave_state = CONST_INT['slave_exist']:

		if $dynslave_psy_status = 'broken':
			! mind-broken slaves are indifferent
		elseif dynslave['moral'] < 5 and instr($interaction_type, 'rape') ! 0:
			! rape is opposed by nature ([-20, -4]) unless fully devoted - ImperatorAugustus
			interaction_dynslave['sex_acceptance'] -= (dynslave['ego'] + dynslave['temper'] + dynslave['pride'] + dynslave['intellect'])
		elseif stimulating > 0 or orgastic > 0:
			interaction_dynslave['sex_acceptance'] = (master_style - 5) + dynslave['mood'] + dynslave['moral'] + dynslave['arousal']*2 - dynslave['pride']*2
			! initial value ranges from +20 (alluring master, ecstatic, max devotion, max arousal, no pride) to -20 (repulsive master, depressed, no devotion, no arousal, max pride)
			if $dynslave_psy_status = 'frightened' or $dynslave_psy_status = 'docile':
				interaction_dynslave['sex_acceptance'] += dynslave['fear'] &! a frightened or docile slave is most motivated by fear - ImperatorAugustus
			elseif $dynslave_psy_status = 'horny':
				interaction_dynslave['sex_acceptance'] += dynslave['arousal'] &! a horny slave is most motivated by arousal - ImperatorAugustus
			elseif $dynslave_psy_status = 'servile':
				interaction_dynslave['sex_acceptance'] += dynslave['ego'] &! a devoted slave subordinates their nature - ImperatorAugustus
			elseif $dynslave_psy_status = 'obedient':
				interaction_dynslave['sex_acceptance'] += dynslave['intellect'] &! an obedient slave is most motivated by rationality - ImperatorAugustus
			elseif $dynslave_psy_status = 'hysteric':
				interaction_dynslave['sex_acceptance'] -= dynslave['moral'] &! being hysteric (spoiled) counters devotion - ImperatorAugustus
			elseif $dynslave_psy_status = 'hateful':
				interaction_dynslave['sex_acceptance'] -= dynslave['temper'] &! a hateful slave is most motivated by temperament - ImperatorAugustus
			elseif $dynslave_psy_status = 'resistant':
				interaction_dynslave['sex_acceptance'] -= dynslave['ego'] &! a resistant slave is most motivated by nature - ImperatorAugustus
			elseif $dynslave_psy_status = 'arrogant':
				interaction_dynslave['sex_acceptance'] -= dynslave['pride'] &! an arrogant slave is most motivated by pride - ImperatorAugustus
			elseif $dynslave_psy_status = 'reluctant' or $dynslave_psy_status = 'depresive' or $dynslave_psy_status = 'lachrymose':
				interaction_dynslave['sex_acceptance'] += dynslave['sensitivity'] &! sensitivity determines the impact of angst, which reduces resistance - ImperatorAugustus
			end
			if dynslave['nymphomania'] > 0: interaction_dynslave['sex_acceptance'] += dynslave['arousal'] &! nymphomania increases arousal weight - ImperatorAugustus
			if dynslave['nymphomania'] < 0: interaction_dynslave['sex_acceptance'] -= dynslave['sensitivity'] &! frigidity increases resistance proportional to sensitivity - ImperatorAugustus
			! above factors range from [-10, +10] (without nymphomania/frigidity, [-5, +5]), below factors range from [-20, +40]
			interaction_dynslave['sex_acceptance'] += dynslave['sex_sum']/4 &! acceptance rises with experience (average of all sex skills adds [0, 8])
			if shameful > 0:
				interaction_dynslave['sex_acceptance'] += 4*dynslave['exhibitionism']
			end
			if painful > 0:
				interaction_dynslave['sex_acceptance'] += 4*dynslave['masochism']
			end
			if disgusting > 0:
				interaction_dynslave['sex_acceptance'] += 4*dynslave['perversion']
			end
			if lesbian > 0:
				interaction_dynslave['sex_acceptance'] += 4*dynslave['homosexualism']
			elseif dynslave['homosexualism'] = 2:
				interaction_dynslave['sex_acceptance'] -= 8 &! lesbians dislike non-lesbian activities
			end

			! sum of all factors ranges from [-50,+70]
			interaction_dynslave['sex_acceptance'] /= 2 &! final value is in range [-25, +35] but usually single digits

		end &! end of stimulating check

	end &! end of conscious state check
}

$dyn_repulse_check = {
	! called from interaction_result
	! sets result interaction_*['res'], which if < 0 indicates the slave refuses the interaction
	! if slave has a positive or negative affinity ($target_affinity set by caller), it has a large impact (+/- 5)
	! a slave will answer what she wants to do at (-1 + pride) obedience
	! going from +3 mood to <= 0 mood drops obedience by 2, which is less than the +5 bonus for a positive affinity
	! this means that a slave will be willing to do the thing they said they want to do even if their mood drops
	! expects to be called with dynamic $replace($dyn_repulse_check, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist']:

		!if dynslave['domini_dictum'] = 1:
		!	interaction_dynslave['res'] = 0
		!if 'dynslave' = 'assistant':
		!	interaction_dynslave['res'] = dynslave['moral'] &! TODO: for now, devoted assistants do not refuse anything - ImperatorAugustus
		!else
			interaction_dynslave['res'] = dynslave['obedience'] + interaction_dynslave['sex_acceptance'] - interaction_dynslave['repulse']
			! for rape or actions the slave finds distasteful, sex_acceptance may be negative, making it harder to overcome the repulse threshold
			if $target_affinity ! '':
				if $interaction_partner = 'dynslave': dynslave[$target_affinity + '_revealed'] = max(1, dynslave[$target_affinity + '_revealed'])
				if dynslave[$target_affinity] < 0: interaction_dynslave['res'] -= 5
				if dynslave[$target_affinity] > 0: interaction_dynslave['res'] += 5
			end
		!end

		if $interaction_partner = 'dynslave' and interaction_dynslave['res'] >= 0: dynslave['daring'] = max(dynslave['daring'], interaction_dynslave['repulse']) &! this is used to limit merit, increases here and decreases in next_day

	elseif dynslave_state = CONST_INT['slave_faint']:

		interaction_dynslave['res'] = 0 &! unconscious slaves cannot resist - ImperatorAugustus

	end &! end of conscious/fainted state checks
}

$dyn_diligence = {
	! called from interaction_result after $dyn_repulse_check
	! sets interaction_*['diligence'] in range [0,5], zero reflects inadequate/lackluster effort, positive reflects praise-worthy effort
	! interaction_*['motivation_repulse'] can be set by caller in [0,5] range as a malus to overcome (motivation_repulse affects only diligence, not obedience)
	! this function adjusts diligence to account for $target_affinity, if set by caller (affinities have strong influence)
	! this function also imposes a range of [0, diligence] on the sex_quality global (which represents the slave applying skills to improve sex for partner)
	! expects to be called with dynamic $replace($dyn_diligence, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist']:

		interaction_dynslave['diligence'] = dynslave['mood'] + dynslave['moral'] + dynslave['fear'] - dynslave['angst']/2 - dynslave['spoil'] &! initial value is in range [-12, +15]

		! AURA-BASED MOTIVATION
		interaction_dynslave['motivation_repulse'] = max(0, min(5, interaction_dynslave['motivation_repulse'])) &! enforce [0,5] range (default 0)
		if dynslave['custom']     > interaction_dynslave['motivation_repulse']: interaction_dynslave['diligence'] += 1
		if dynslave['instinct']   > interaction_dynslave['motivation_repulse']: interaction_dynslave['diligence'] += 1
		if dynslave['rational']   > interaction_dynslave['motivation_repulse']: interaction_dynslave['diligence'] += 1

		! ITEM BONUSES
		if $target_skill ! '':
			dynamic $replace($recalc_equipment_bonuses, 'dyn'+'slave', 'dynslave') &! refresh learn_bonus for slave (used in $misc_bonus)
			interaction_dynslave['diligence'] += dyneval('result = learn_bonus[$target_skill]') &! item bonuses increase diligence
		end

		! PHOBIAS
		phobia = 0
		if shameful > 0:     phobia += dynslave['exhibitionism'] - shameful
		if painful > 0:      phobia += dynslave['masochism'] - painful
		if abuse > 0:        phobia += dynslave['abuse_attitude'] - abuse
		if disgusting > 0:   phobia += dynslave['perversion'] - disgusting
		if darkness > 0:     phobia += dynslave['darkness_attitude'] - darkness
		if bloody > 0:       phobia += dynslave['blood_attitude'] - bloody
		if fire_based > 0:   phobia += dynslave['fire_attitude'] - fire_based
		if water_based > 0:  phobia += dynslave['water_attitude'] - water_based
		if vermin_based > 0: phobia += dynslave['vermin_attitude'] - vermin_based
		if deprivation > 0:  phobia += dynslave['deprivation_attitude'] - deprivation
		if lesbian > 0:      phobia += dynslave['homosexualism'] - lesbian
		if stimulating > 0:  phobia += dynslave['nymphomania'] &! no offset because nymphomania only goes up to +1, all above go to +2
		interaction_dynslave['diligence'] += phobia &! will be positive or negative depending on relevant attitudes

		! NEGATIVE FACTORS
		if dynslave['energy'] < 0: interaction_dynslave['diligence'] += dynslave['energy']*4 &! exhaustion directly reduces diligence
		if stimulating > 0 or orgastic > 0: interaction_dynslave['diligence'] -= dynslave['pride'] - dynslave['arousal']/5 &! pride opposes sex, maxed arousal does the opposite
		if rebell[$dynslave_psy_status] < 0: interaction_dynslave['diligence'] += rebell[$dynslave_psy_status] &! currently a [-100,-1] range
		if rebell[$dynslave_psy_status] > 0: interaction_dynslave['diligence'] -= rebell[$dynslave_psy_status] &! currently a [0,4] range
		if interaction_dynslave['res'] < 0: interaction_dynslave['diligence'] += interaction_dynslave['res']/2 &! when refusal is not possible (tutor, academy)

		! BONUSES FOR TEACHING ABILITY
		if $interaction_type = 'master_teaches_slave':
			interaction_dynslave['diligence'] += max(0, master_tutor - 2) &! +1 with B+ teaching skill, +2 with A+ teaching skill, +3 with S+ teaching skill
		elseif $interaction_type = 'assistant_teaches_slave' and assistant['intellect'] > 3:
			interaction_dynslave['diligence'] += (assistant['intellect'] - 3) &! assistants with A+ or S+ intellect boost diligence by +1 or +2
		elseif $interaction_type = 'school_class':
			interaction_dynslave['diligence'] += 2 &! classes boost diligence by +2
		elseif $interaction_type = 'coach_teaches_slave':
			interaction_dynslave['diligence'] += 3 &! tutors boost diligence by +3
		end

		! NORMAL DIFFICULTY OVERRIDE
		if interaction_dynslave['diligence'] < 2 and difficulty_setting ! 2:
			! except on hardcore obedience difficulty, negative mood has a reduced impact on diligence
			if dynslave['mood'] < 0: interaction_dynslave['diligence'] -= (1+dynslave['mood'])/2 &! subtracting a negative, effectively reversing a portion of the penalty (depressed becomes a -2 instead of -5)
			! except on hardcore obedience difficulty, a slave with non-negative obedience and/or mood will give at least a minimal effort irrespective of above factors
			if max(dynslave['obedience'], dynslave['mood']) >= 0: interaction_dynslave['diligence'] = max(1, interaction_dynslave['diligence'])
		end

		! LINKED PRIMARY TRAIT BONUS/PENALTY
		if $target_affinity ! '':
			if dynslave[$target_affinity] > 0: interaction_dynslave['diligence'] += 10 &! positive affinity negates two out of three: depressed mood, max-angst, max-spoil
			if dynslave[$target_affinity] < 0: interaction_dynslave['diligence'] -= 10 &! negative affinity does the opposite
		end

		! SEX DILIGENCE IS CAPPED WHEN PSY STATUS IS FRIGHTENED, DOCILE, LACHRYMOSE, DEPRESSIVE OR BROKEN
		if (stimulating > 0 or orgastic > 0) and rebell[$dynslave_psy_status] < 0 and interaction_dynslave['diligence'] > 2: interaction_dynslave['diligence'] = 2

		! PSEUDO-RANDOM POSITIVE DILIGENCE WITH MOOD AS LOWER BOUND, OR CAP POSITIVE DILIGENCE AT 1 IF MOOD IS NEGATIVE (HARDCORE ONLY)
		if interaction_dynslave['diligence'] > 1:
			if dynslave['mood'] < 0 and difficulty_setting = 2:
				interaction_dynslave['diligence'] = 1
			elseif dynslave['mood'] < interaction_dynslave['diligence']:
				interaction_dynslave['diligence'] = max(dynslave['mood'], 1 + (48271 * (day + dynslave_type + interaction + dynslave_already_done_total[$str(interaction)]) mod 65537)/(65537/interaction_dynslave['diligence']))
			end
		end

		! SPECIAL CASES
		if dynslave['domini_dictum'] = 1 or $dynslave_psy_status = 'broken':
			interaction_dynslave['diligence'] = 1 &! mind-controlled or mind-broken diligence is locked at 1
		!elseif 'dynslave' = 'assistant':
		!	interaction_dynslave['diligence'] = iif(stimulating > 0, min(5, dynslave['moral'] + dynslave['arousal']/5), dynslave['moral']) &! TODO: assistant ignores other factors for now - ImperatorAugustus
		end

		! CLAMP RESULT
		interaction_dynslave['diligence'] = max(0, min(5, interaction_dynslave['diligence'])) &! enforce [0,5] range

	end &! end of conscious state check
}

$dyn_torture_phobia = {
	! sets interaction_*['phobia'] to the sum of trait values corresponding to an enabled torture flag (shameful, painful, abuse, etc.)
	! for example, if a slave is a Masochist (trait value = 2) and Shy (trait value = -1), the sum +1 confers partial resistance to torture involving both pain and shame
	! expects to be called with dynamic $replace($dyn_torture_phobia, 'dyn'+'slave', 'a slave instance variable')
	! disabled incrementing xp here because this function is called from interaction before determining outcome
	! it is possible that the interaction fails after this function is called, in which case no xp should be gained
	! xp increments have therefore moved to $dyn_torture_result - ImperatorAugustus
	if dynslave_state = CONST_INT['slave_exist']:
		interaction_dynslave['phobia'] = 0
		if painful > 0: interaction_dynslave['phobia'] += dynslave['masochism']
		if shameful > 0: interaction_dynslave['phobia'] += dynslave['exhibitionism']
		if disgusting > 0: interaction_dynslave['phobia'] += dynslave['perversion']
		if abuse > 0: interaction_dynslave['phobia'] += dynslave['abuse_attitude']
		if darkness > 0: interaction_dynslave['phobia'] += dynslave['darkness_attitude']
		if blood > 0: interaction_dynslave['phobia'] += dynslave['blood_attitude']
		if fire_based > 0: interaction_dynslave['phobia'] += dynslave['fire_attitude']
		if water_based > 0: interaction_dynslave['phobia'] += dynslave['water_attitude']
		if vermin_based > 0: interaction_dynslave['phobia'] += dynslave['vermin_attitude']
		if deprivation > 0: interaction_dynslave['phobia'] += dynslave['deprivation']
		! not handling compassion here because it is not necessarily the correct perspective (observer feels compassion, not victim)
		interaction_dynslave['phobia'] = max(-1, min(2, interaction_dynslave['phobia'])) &! limit to range [-1, +2]

	end &! end of conscious state check
}

$dyn_torture_result = {
	!Torture result - improved - crushboss (revised and converted to dynamic by ImperatorAugustus, consolidated moodlet and trait impacts from other locations, including torture xp)
	! clears any sin on the victim, determines torture outcome, inflicts mental effects accordingly, but does not apply any physical effects (e.g., no stamina drain, no damage)
	! for physical effects, if applicable, it is recommended to additionally call $dyn_slave_damaged
	! sets torture_succeeded to 0, 1 or 2 (repectively: minimal effect, moderate effect, maximal effect - including a fear level increase for the slave)
	! expects phobia to be set by an earlier call to $dyn_torture_phobia, and expects torture_intensity, sensitivity_threshold and torturer_skill to be set by caller
	! expects to be called with dynamic $replace($dyn_torture_result, 'dyn'+'slave', 'a slave instance variable')

	! fear_resistance opposes torturer_skill: ego (willpower) and (to a lesser extent) temperament and pride oppose fear, sensitivity increases vulnerability, and previous experience of the same torture increases resistance
	fear_resistance = (dynslave['ego'] - dynslave['sensitivity']) + (dynslave['temper'] + dynslave['pride'])/2
	if abuse > 0: fear_resistance += dynslave_already_done_total[$str(interaction)] &! slaves accumulate lifetime resistance to psychological pressure, but this cannot overcome a phobia - ImperatorAugustus
	! 5 ego, 5 temper, 5 pride, 0 sensitivity -> +10 fear resistance (max value without previous repetitions)
	! 5 ego, 5 temper, 3 pride, 3 sensitivity -> +7 fear resistance
	! 5 ego, 5 temper, 5 pride, 5 sensitivity -> +5 fear resistance
	! 4 ego, 4 temper, 4 pride, 4 sensitivity -> +4 fear resistance
	! 3 ego, 3 temper, 3 pride, 3 sensitivity -> +3 fear resistance
	! 2 ego, 5 temper, 1 pride, 5 sensitivity -> +0 fear resistance
	! 2 ego, 2 temper, 0 pride, 5 sensitivity -> -2 fear resistance
	if interaction_dynslave['phobia'] = 1: fear_resistance *= 2 &! if instead of a phobia the slave has an affinity for the torture type, they are more resistant to it
	if futile_threat = 1: fear_resistance *= 2 &! futile_threat is set when repeating a threat before actually performing the threatened action

	! torturer_skill should be set by caller for the specific interaction to the average [0,5] of applicable specific skills of the torturer (e.g., dominance for verbal abuse, flagellation for whipping)
	if dynslave['sensitivity'] > max(sensitivity_threshold, (1 + torturer_skill)/2, futile_threat*5): dynslave_rate['sensitivity'] -= dynslave['sensitivity']
	! futile_threat*5 in the line above negates sensitivity damage when futile_threat is set to 1 by the caller because max sensitivity is 5, and 5 > 5 is always false
	! master skill can prevent sensitivity dropping below half of master skill level, rounded up: skillfully reducing damage, but not fully negating it (max master skill prevents lowering sensitivity below B+)

	torturer_skill += 5 + torture_intensity &! after sensitivity check, add baseline to torturer_skill (makes punishments effective for an unskilled master - higher tiers are more effective / can be repeated more times)
	! an average slave with all B+ stats has +3 fear resistance initially, against which an unskilled master gets 3 effective uses of chastise punishment (6 vs. 3, 6 vs. 4 due to +1 from already_done_total, 6 vs. 5, 6 vs. 6 = fail)
	! a high-tier slave with all A+ stats has +4 fear resistance initially, against which an unskilled master gets 2 effective uses of chastise punishment (6 vs. 4, 6 vs. 5 due to +1 from already_done_total, 6 vs. 6 = fail)
	! a top-tier slave with all S+ stats has +10 fear resistance initially, against which an unskilled master gets no effective uses of chastise punishment (6 vs. 10)

	! torture always drops mood regardless of outcome (only if slave has an associated phobia - ImperatorAugustus)
	if interaction_dynslave['phobia'] < 0: gs '$mood_drop', 'dynslave', torture_intensity
	! if interaction_dynslave['phobia'] = 0: gs '$mood_drop', 'dynslave', 1 &! disabled general mood drop for non-phobia, neg moodlets are enough - ImperatorAugustus
	!TODO: dynslave_rate['mood'] -= dynslave['sensitivity'] &! temporary mood decrease ranging from 0 at no sensitivity to -0.5 at 5 sensitivity and tier 5 intensity (negative mood translates to angst overnight)

	if dynslave['sin'] = 0: dynslave_rate['rational'] -= dynslave['intellect'] &! being punished when feeling no guilt lowers awareness (rational motivation to obey to avoid punishment), smarter slaves are more affected - ImperatorAugustus

	!determine outcome: 0 = only negative impacts (sensitivity/fear/taming drain), 1 = positive impacts if matched to guilt - +awareness/+taming [if painful or deprivation], 2 = same as 1 plus fear increase [proportional to sensitivity]
	if dynslave['courage'] = -1:
		torture_succeeded = 2 &! slave is a coward (easily frightened) so torture always raises fear
		if dynslave['courage_revealed'] = 0: dynslave['courage_revealed'] = 1
	elseif interaction_dynslave['phobia'] = 2 or dynslave['courage'] = 2:
		torture_succeeded = 0 &! slave has a trait aligned with the activity or has the moronic trait (impossible to frighten)
		if dynslave['courage_revealed'] = 0: dynslave['courage_revealed'] = 1
	elseif interaction_dynslave['phobia'] = -1:
		torture_succeeded = 2 &! always increase fear when exploiting slave phobia (unless moronic)
	elseif torturer_skill < fear_resistance:
		torture_succeeded = 0
	else
		torture_succeeded = iif(torture_intensity >= dynslave['fear'], 2, 1) &! increase fear if torture intensity matches or exceeds current fear (possible to max fear without using tier-5 punishments)
	end

	if torture_succeeded = 2: dynslave_rate['fear'] += torture_intensity * (2 + dynslave['sensitivity']) &! the gentle slave is easier affected by stress and stung by punishments

	if torture_succeeded = 0 or dynslave['sin'] > torture_intensity:
		! torture ineffective due to fear resistance or aligned trait or too-lenient punishment (lower tier than guilt) lowers fear and increases spoiling
		if dynslave['fear'] > torture_intensity: dynslave_rate['fear'] -= max(torture_intensity, dynslave['sin'] - torture_intensity) &! lower fear towards but not below the level of the punishment - ImperatorAugustus
		if dynslave['sin'] > torture_intensity: dynslave_rate['spoil'] += dynslave['temper'] &! spoil increase reflects the slave feeling safer defying the slaver - temperament measures initiative (strength of personal desires)
		if rebell[$dynslave_psy_status] <= 0: $dynslave_psy_status = 'resistant' &! temporary status change for better text selection
		dynslave['pos_ineffective_punishment'] = max(dynslave['pos_ineffective_punishment'], torture_intensity)
		dynslave['merit'] = 0 &! reset merit - being under-punished can be viewed as a reward, but does not make the slave more motivated to obey the slaver (if disobedience is rewarded, disobedience is reinforced)
	else
		dynslave['pos_ineffective_punishment'] = 0
		! probabilistic formula by utterlyjunky to increase max_guilt (guilt cap used by $sin_gained_now), capped to not increase above current fear + 1
		if dynslave['max_guilt'] <= dynslave['fear'] and (rand(1,20) + master_domination - dynslave['ego']) > 14: dynslave['max_guilt'] = min(5, dynslave['max_guilt'] + 1)
		if dynslave['max_guilt'] < dynslave['fear'] and rand(0,3) = 0: dynslave['max_guilt'] += 1 &! 25% catch-up chance when fear is higher than guilt cap

		if dynslave['sin'] > 0:
			! successful torture at or above the level of guilt the slave feels (if the slave does feel guilt) builds rational obedience - ImperatorAugustus
			dynslave_rate['rational'] += (1+dynslave['intellect'])/2 &! smarter slaves gain awareness faster - if no guilt, they will instead lose awareness (above)
			msm = max(1, min(5, master_supermacy)) &! limit to [1,5] range
			if difficulty_setting < 2:
				if msm > 0:
					dynslave_rate['pride'] -= (torture_intensity + msm)
				else
					dynslave_rate['pride'] -= torture_intensity
				end
			end
			if painful > 0 or deprivation > 0: dynslave_rate['instinct'] += msm &! pain or deprivation (restriction of mobility) increase taming proportional to the perceived superiority of the master
			! these increases are not capped or limited and can be repeated multiple times per day at the cost of energy and mood (negative mood translates to angst overnight)
		end
		dynamic $replace($newloc_update_slave, 'dyn'+'slave', 'dynslave') &! update stats and potentially change psy status as a result for better text selection and obedience bonus determination
		if dynslave['sin'] < torture_intensity:
			! torture intensity above guilt increases angst and, if angst is already maxed, directly drains stats - ImperatorAugustus
			dynslave_rate['angst'] += torture_intensity + dynslave['sensitivity']*2
			if dynslave['angst'] = 5: dynslave_rate['temper'] -= 5 & dynslave_rate['ego'] -= 5 &! drain stats directly when angst is already maxed - ImperatorAugustus
			$dynslave_psy_status = 'lachrymose' &! temporary status change (overriding update above) for better text selection
		end
	end

	! guilt reset (only after checking it above) - ImperatorAugustus
	dynslave['sin'] = 0
	dynslave['pos_no_punish'] = 0 &! punishment removes this moodlet if it was active - ImperatorAugustus

	dynslave['daily_punishment_count'] += 1 &! daily punishment count is reset in next_day
	if dynslave['daily_punishment_count'] > 2: dynslave_rate['angst'] += (dynslave['daily_punishment_count'] * 5)

	!increase applicable trait xp, reveal applicable hidden traits and clear pain threat if applicable (relocated to interaction_result)

	$удача_пытки[0] = 'наказание провалилось'
	$удача_пытки[1] = 'наказание успешно, без повышения страха'
	$удача_пытки[2] = 'наказание успешно, c повышением страха'
	!msg уровень пытки = <<torture_intensity>>
	!эффективность пытки = <<torturer_skill>>
	!Фактор фобий = <<interaction_dynslave['phobia']>>
	!сопротивляемость рабыни = <<fear_resistance>>
	!Результат: <<$удача_пытки[torture_succeeded]>>
	!Новый уровень страха: <<slave["fear"]>>
}

$dyn_reward_potence = {
	! utility function for interaction_result, modifies interaction_reward_potence 'local' variable (cleared and set by interaction, used by interaction_result)
	! expects to be called with dynamic $replace($dyn_reward_potence, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist']:

		if dynslave_already_done_total[$str(interaction)] = 0: interaction_reward_potence += 1
		interaction_reward_potence += dynslave['moral']
		if dynslave['obedience'] < 0: interaction_reward_potence += dynslave['obedience']
		if interaction_reward_potence <= 0: interaction_reward_potence = 1

	end &! end of conscious state check
}

!Erotic Stimulation - slave
$dyn_erotic_stimulation = {
	! called from interaction_result, sets interaction_*['final_stimulation'] and calls $slave_orgasm if orgastic > 0 (global set by caller) and sufficient stimulation
	! if orgastic > 0 and stimulation is sufficient, adds nymphomania xp, reveals nymphomania, adds text to $orgasm_text array with orgasm description
	! otherwise, increases arousal proportional to stimulation amount (which is boosted by existing arousal and the sensitivity level of the slave)
	! expects to be called with dynamic $replace($dyn_erotic_stimulation, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave'] and interaction_dynslave['erotic_stimulation'] > 0:
		! state check includes fainted (TODO: stamina drain [implemented elsewhere] for sexing fainted slaves?) - ImperatorAugustus
		if rebell[$dynslave_psy_status] > 0: interaction_dynslave['erotic_stimulation'] = 1 + interaction_dynslave['erotic_stimulation']/10
		interaction_dynslave['erotic_stimulation'] = min(22, max(0, interaction_dynslave['erotic_stimulation'])) &! total stimulation is capped within [0,22] range
		interaction_dynslave['final_stimulation'] = interaction_dynslave['erotic_stimulation'] * max(1, dynslave['arousal']) &! arousal above 1 increases stimulation

		! below code calling $slave_orgasm consolidated here from individual interactions to reduce copy/paste - ImperatorAugustus
		if orgastic > 0 and (interaction_dynslave['final_stimulation'] >= (22 - dynslave['arousal']*3) or dynslave['arousal'] = 5):
			orgastic = max(orgastic, interaction_dynslave['final_stimulation']/22) &! number of orgasms [1,5]
			dynslave['nymphomania_xp'] += (1 + orgastic)/2
			dynamic $replace($dyn_slave_orgasm, 'dyn'+'slave', 'dynslave') &! protect from earlier replace
			if orgasm_description ! 0:
				dynamic $replace(' $orgasm_text[] = ''<<$orgasm_description[orgasm_description]>>'' ', 'dyn'+'slave', 'dynslave') &! evaluate delayed sub-expressions
				if orgastic > 1: $orgasm_text[arrsize('$orgasm_text')-1] = $replace($orgasm_text[], 'cums violently', 'cums repeatedly, shuddering for almost half a minute before relaxing')
				! $orgasm_text will be appended to $text array and cleared at the end of interaction_result
				orgasm_description = 0
			end
		elseif dynslave['nymphomania'] >= 0:
			! accumulate arousal (unless frigid)
			dynslave_rate['arousal'] += (interaction_dynslave['final_stimulation'] * (2 + dynslave['sensitivity']))/2
		end

	end &! end of conscious or fainted state check (and stimulation > 0)
}

!Slave Orgasm - overhauled by crushboss
$dyn_slave_orgasm = {
	! called from $dyn_erotic_stimulation and interaction_result (self_sex_lesson_special easter egg effect)
	! expects to be called with dynamic $replace($dyn_slave_orgasm, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		if orgastic < 1: orgastic = 1 & msg '$dyn_slave_orgasm called with orgastic < 1, please report this!' &! default to 1 if caller did not set it
		if dynslave['no_orgasm_rule'] = 0 or dynslave_state = CONST_INT['slave_faint'] or ('dynslave' ! 'slave' and cow_lesson_in_progress ! 1):
			! fainted slaves cannot be expected to follow rules - ImperatorAugustus
			! non-slaves are not required to follow no-orgasm rule (extra check added for cow lesson which swaps active slave to cow) - ImperatorAugustus
			!TODO: expose no_orgasm_rule on assistant_stat
			orgasm_description = 1

			dynslave['pos_orgasm'] += 1 &! moodlet exponentially decays in next_day -ImperatorAugustus
			dynslave_rate['arousal'] -= interaction_dynslave['final_stimulation'] * (dynslave['arousal'] + orgastic * dynslave['temper'])
			dynslave_rate['temper'] += orgastic &! +1 per orgasm
			if dynslave['temper'] > dynslave['pride']: dynslave_rate['instinct'] += 1

		elseif dynslave['no_orgasm_rule'] = 1:
			if interaction_dynslave['final_stimulation'] <= dynslave['obedience']:
				orgasm_description = 2

				if dynslave['nymphomania'] >= 0:
					! accumulate arousal (unless frigid)
					dynslave_rate['arousal'] += (interaction_dynslave['final_stimulation'] * (2 + dynslave['sensitivity']))/2
				end
				dynslave_rate['sensitivity'] += orgastic &! +1 per orgasm resisted
				if dynslave['temper'] > dynslave['pride']: dynslave_rate['instinct'] += 1

			elseif interaction_dynslave['final_stimulation'] > dynslave['obedience']:
				orgasm_description = 3

				dynslave['pos_orgasm'] += 1 &! moodlet exponentially decays in next_day -ImperatorAugustus
				dynslave_rate['arousal'] -= interaction_dynslave['final_stimulation'] * (dynslave['arousal'] + orgastic * dynslave['temper'])
				dynslave_rate['temper'] += orgastic &! +1 per orgasm
				dynslave_rate['instinct'] -= dynslave['instinct'] &! breaking the rule reduces taming - ImperatorAugustus
				dynamic $sin_gained_now, 'dynslave', 3 &! cap sin at level 3 (was capped at greatest of 2, devotion or instinct) - ImperatorAugustus

			end
		end

	end &! end of conscious or fainted state check - ImperatorAugustus
}

$dyn_advance_sex_skills = {
	! used by self_sex_lesson in interaction_result
	! expects caller to have set success variable
	! expects caller to have set $subskill, $subskill_xp, and optionally $subskill_two and $subskill_two_xp
	! caution: does not reset rise_difficulty, $subskill, $subskill_xp, $subskill_two or $subskill_two_xp, cleanup is caller responsibility
	! updates the designated subskills accordingly
	! expects to be called with dynamic $replace($dyn_advance_sex_skills, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		if $subskill ! '' and $subskill_xp ! '':
			if dyneval($replace('result = <<$subskill>>', 'slave', 'dynslave')) < 5:
				dynamic $replace('success += <<$subskill_xp>>', 'slave', 'dynslave') &! add accumulated progress from previous lesson(s)
				if success >= rise_difficulty or dyneval($replace('result = <<$subskill>>', 'slave', 'dynslave')) = 0:
					! first transition (F- to D-) is always successful
					dynamic $replace('<<$subskill>> += 1', 'slave', 'dynslave') &! skill_adv_mul here skipped entire levels, so removed (xp multiplier below is enough) - ImperatorAugustus
					dynamic $replace('<<$subskill_xp>> = 0', 'slave', 'dynslave') &! reset accumulated progress
					if $subskill_two ! '' and $subskill_two_xp ! '':
						dynamic $replace('if <<$subskill_two>> < 5: <<$subskill_two_xp>> += 1', 'slave', 'dynslave') &! secondary skills get a small xp boost (line order here is important - add xp before level-up/reset, not after)
						dynamic $replace('if <<$subskill_two>> < 1: <<$subskill_two>> += 1 & <<$subskill_two_xp>> = 0', 'slave', 'dynslave') &! secondary skills only advance from F- to D- in incidental (not the focus of the lesson) training
					end
				else
					dynamic $replace('<<$subskill_xp>> += skill_adv_mul * max(2, success - <<$subskill_xp>>)', 'slave', 'dynslave') &! accumulate partial success (subtracting xp here avoids compounding), with a minimum of 2
					if $subskill_two_xp ! '': dynamic $replace('if <<$subskill_two>> < 5: <<$subskill_two_xp>> += 1', 'slave', 'dynslave') &! secondary skills get a small xp boost
				end
			end
		end

	end
}

$dyn_advance_sex_skills_nolesson = {
	! used in various places for non-lesson sex skill progression
	! expects caller to have set rise_difficulty and rise_mod
	! expects caller to have set $subskill, $subskill_xp, and optionally $subskill_two and $subskill_two_xp
	! caution: will reset $subskill, $subskill_xp, $subskill_two, $subskill_two_xp, rise_difficulty and success unless caller passes 'noreset' as $args[0]
	! calls $dyn_advance_sex_skills to update the designated subskills
	! expects to be called with dynamic $replace($dyn_advance_sex_skills_nolesson, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		if $subskill ! '' and $subskill_xp ! '':

			args[1] = success &! save value to restore later
			args[2] = rise_difficulty &! save value to restore later
			success = 0 &! minimum progress rate
			rise_difficulty = 12 + max(1, dyneval($replace('result = <<$subskill>>', 'slave', 'dynslave')))*34 &! should be higher than maximum rise_difficulty in lessons, including rise_mod, hence 12 + 22 = 34
			dynamic $replace($dyn_advance_sex_skills, 'dyn'+'slave', 'dynslave') &! primary sex skills advance slowly, uncapped, in incidental (non-lesson) training; secondary skills only advance from F- to D-
			! F- to D- is guaranteed success, D- to C- is 46/2 = 23 repetitions, C- to B+ is 80/2 = 40 repetitions, B+ to A+ is 114/2 = 57 repetitions, A+ to S+ is 148/2 = 74 repetitions, in total 1 + 23 + 40 + 57 + 74 = 195 repetitions

			if $args[0] ! 'noreset':
				$subskill = ''
				$subskill_xp = ''
				$subskill_two = ''
				$subskill_two_xp = ''
				rise_difficulty = 0
				success = 0
			else
				success = args[1]
				rise_difficulty = args[2]
			end
		end

	end
}

!Sin Gained - overhauled by crushboss (overhauled again by ImperatorAugustus, see notes below)
! Revised to introduce a progression of guilt (as described in the game tutorial) tied to reasoned or instinctive internalization of slavery (credit to utterlyjunky for suggesting a progression and developing the formula)
! Instead of being essentially random with hard-coded fixed upper limits for each interaction, the highest level of guilt that can be felt by a slave is now capped by a max_guilt internal variable. Interactions can set upper bounds on the maximum amount of guilt they could possibly give to a slave (although many will not). For example, a comparatively "minor" violation like cumming with no-orgasm rule could be limited to 3 guilt even for a perfectly devoted slave. Meanwhile, a new slave with an uninitialized max_guilt would feel the minimum guilt (1) even for a "severe" infraction. I considered even letting disobedient slaves feel no guilt at all, but many texts in the game are written assuming that guilt is awarded (almost all of the interaction refusal texts, for example), so I kept the minimum at 1 for now.
! I also changed the behavior of gaining guilt on top of existing guilt. Now it replaces previous guilt only if the potential guilt of the new infraction is greater. Further, if a slave gains more guilt on top of unpunished existing guilt, they will lose a small amount of reflexive superiority-based obedience (aka instinct/taming). So repeatedly asking a slave to do things they refuse to do will drain their obedience in that way. I deliberately did not include increases in stats like pride or ego, even though those would "realistically" be boosted when a slave disobeys, because I did not want this to become a possible exploit for raising those stats (pride is not gameplay beneficial, but can be interesting for "roleplay" purposes, while ego/nature increases the market value of a slave).
$sin_gained_now = {
	dynamic "
		if <<$args[0]>>_state = CONST_INT['slave_exist'] and '<<$args[0]>>' = 'slave':
			! TODO: only primary slave can gain sin (for now) - ImperatorAugustus

			if <<$args[0]>>['meekness'] < 0 and <<$args[0]>>['meekness_revealed'] = 0: <<$args[0]>>['meekness_revealed'] = 1

			! code calling $sin_gained_now can pass an optional numeric second parameter to define an upper bound - ImperatorAugustus
			interaction_<<$args[0]>>['sin_potential'] = <<args[1]>>

			! code calling $sin_gained_now can also set sin_potential first to define an upper bound, 5 is default - ImperatorAugustus
			if interaction_<<$args[0]>>['sin_potential'] <= 0: interaction_<<$args[0]>>['sin_potential'] = 5

			! added taming drain when slaves gain additional guilt on top of guilt already felt (e.g., refusing a second order after refusing the first) - ImperatorAugustus
			if <<$args[0]>>['sin'] > 0: <<$args[0]>>_rate['instinct'] -= <<$args[0]>>['sin']

			if <<$args[0]>>['obedience'] > 0:
				! set sin potential for obedient slaves to a pseudo-random value between 1 and itself
				interaction_<<$args[0]>>['sin_potential'] = 1 + (48271 * (day + <<$args[0]>>_already_done_total[$str(interaction)]) mod 65537)/(65537/interaction_<<$args[0]>>['sin_potential'])
			end

			! calculate potential guilt level as lesser of sin potential or max_guilt (see $dyn_torture_result), increased by sententia veritas is active, capped within [1,5] range
			interaction_<<$args[0]>>['sin_potential'] = max(1, min(5, min(interaction_<<$args[0]>>['sin_potential'], <<$args[0]>>['max_guilt']) + <<$args[0]>>['sententia_veritas'] ) )
			if <<$args[0]>>['sententia_veritas'] > 0: <<$args[0]>>['sententia_veritas'] = 0 &! clear the spell after applying the effect

			! guilt no longer accumulates, instead potential guilt replaces existing guilt only if potential guilt is greater than existing guilt - ImperatorAugustus
			<<$args[0]>>['sin'] = max(<<$args[0]>>['sin'], interaction_<<$args[0]>>['sin_potential'])

			! irrespective of whether we replaced existing guilt, reduce existing merit by the amount of new (potential) guilt - ImperatorAugustus
			<<$args[0]>>['virtue'] -= min(<<$args[0]>>['virtue'], interaction_<<$args[0]>>['sin_potential'])

			interaction_<<$args[0]>>['sin_potential'] = 0 &! reset variable

			master_moodlet['pos_nice_slave'] = 0
			if interaction_<<$args[0]>>['res'] < 0:
				! only apply rebellious slave moodlet and master mood drop for interaction refusals, not for inadequate diligence - ImperatorAugustus
				master_moodlet['neg_rebell'] = 1
				gs '$mod_master_drop', 1

				! slightly lower taming and angst and increase ego when the slave refuses (once per day per slave) - ImperatorAugustus
				if <<$args[0]>>_already_done_today['sin_gained_with_negative_res'] = 0:
					<<$args[0]>>_already_done_today['sin_gained_with_negative_res'] = 1
					<<$args[0]>>_rate['instinct'] -= <<$args[0]>>['ego'] &! Instinctual obedience is reduced when the slave successfully disobeys, undermining the perception that the master is superior
					<<$args[0]>>_rate['angst'] -= 2
					<<$args[0]>>_rate['ego'] += 2
				end
			end

		end &! end of conscious state check - ImperatorAugustus
	"
}

!Virtue Gained - overhauled by crushboss
$virtue_gained_now = {
	! called by $dyn_skill_rise and interaction_result
	! if prior virtue exists, it will be added to new virtue only if the slave feels no guilt; otherwise new merit, if greater, will replace old merit
	dynamic "
		if slave_state = CONST_INT['slave_exist'] and '<<$args[0]>>' = 'slave':
			! TODO: only primary slave can gain virtue (for now) - ImperatorAugustus

			if <<$args[0]>>['meekness'] > 0 and <<$args[0]>>['meekness_revealed'] = 0: <<$args[0]>>['meekness_revealed'] = 1
			!if <<$args[0]>>_already_done_today[$str(interaction)] = 0:
				virtue_gained = 1 + ((48271 * (day + dynslave_type + interaction + <<$args[0]>>_already_done_total[$str(interaction)])) mod 65537)/(65537/max(1, min(<<$args[0]>>['temper'], interaction_<<$args[0]>>['diligence'] + <<$args[0]>>['spoil']*2 - <<$args[0]>>['moral'] - <<$args[0]>>['daily_reward_count']))) - <<$args[0]>>_already_done_recent[$str(interaction)] - <<$args[0]>>_already_done_today[$str(interaction)] &! potential merit is capped by temperament (to a minimum of 1), oft-repeated tasks give less merit, devoted slaves feel less deserving, spoiled slaves feel more deserving, and slaves who were already rewarded in the same day expect less subsequent rewards - ImperatorAugustus & qwertyu12359
				if interaction_<<$args[0]>>['repulse'] >= <<$args[0]>>['daring']: virtue_gained += 1
				if virtue_gained > 1 and interaction_<<$args[0]>>['repulse'] < <<$args[0]>>['daring'] - 8: virtue_gained -= 1
				if virtue_gained > 1 and $<<$args[0]>>_psy_status = 'frightened': virtue_gained -= 1
				if virtue_gained > 1 and <<$args[0]>>['angst'] > 0: virtue_gained -= 1
				if <<$args[0]>>['moral'] = 5: virtue_gained -= 1
				if virtue_gained <= 0: virtue_gained = 0
				if virtue_gained > 5: virtue_gained = 5
				if virtue_gained >= <<$args[0]>>['sin']:
					if <<$args[0]>>['moral'] = 5 and <<$args[0]>>['intellect'] > 3 and <<$args[0]>>['selfesteem'] >= 0:
						! prior guilt can be fully canceled by new merit if the slave is fully devoted, Clever or Intelligent, and has neutral or positive self-esteem - ImperatorAugustus & qwertyu12359
						! Guilt is an expectation of punishment. A fully devoted slave believes wholeheartedly that by doing what the master wants, they are doing The Right Thing.
						! A sufficiently clever, devoted slave reasons that if master chooses not to punish them when they feel guilty, master must have a good reason.
						! Instead of doubting it, they will put their whole focus into the next task and fully feel the merit they gain from it.
						<<$args[0]>>['sin'] = 0
					elseif <<$args[0]>>['sin'] > 0:
						! otherwise, retain some residual guilt - ImperatorAugustus & qwertyu12359
						<<$args[0]>>['sin'] = 1
					end
				else
					<<$args[0]>>['sin'] -= virtue_gained
					virtue_gained = 0
				end
				if virtue_gained >= <<$args[0]>>['virtue']:
					<<$args[0]>>['virtue'] += virtue_gained
					master_moodlet['pos_nice_slave'] = 2
					master_moodlet['neg_rebell'] = 0
				end
			!end
			if <<$args[0]>>['sententia_veritas'] > 0:
				!intentionally outside the already-done-today condition
				<<$args[0]>>['virtue'] += <<$args[0]>>['sententia_veritas']
				<<$args[0]>>['sententia_veritas'] = 0
			end
			if <<$args[0]>>['virtue'] > 5: <<$args[0]>>['virtue'] = 5
			if interaction_<<$args[0]>>['diligence'] < (2 + <<$args[0]>>['moral'] - <<$args[0]>>['spoil'])/2: dynamic $sin_gained_now, '<<$args[0]>>' &! when diligence is less than half devotion offset by spoil, slave feels guilt - ImperatorAugustus
			virtue_gained = 0

		end &! end of conscious state check - ImperatorAugustus
	"
}

$dyn_virtue_gained_eroles = {
	! only one calling location: interaction_result (for self_sex_lesson)
	! expects to be called with dynamic $replace($dyn_virtue_gained_eroles, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist'] and 'dynslave' = 'slave':
		! TODO: only primary slave can gain virtue (for now) - ImperatorAugustus

		if dynslave['meekness'] > 0 and dynslave['meekness_revealed'] = 0: dynslave['meekness_revealed'] = 1
		!if dynslave_already_done_today[$str(interaction)] = 0:
			virtue_gained = 1 + ((48271 * (day + dynslave_type + interaction + dynslave_already_done_total[$str(interaction)])) mod 65537)/(65537/max(1, min(dynslave['temper'], interaction_dynslave['diligence'] + dynslave['spoil']*2 - dynslave['moral'] - dynslave['daily_reward_count']))) - dynslave_already_done_recent[$str(interaction)] - dynslave_already_done_today[$str(interaction)] &! potential merit is capped by temperament (to a minimum of 1), oft-repeated tasks give less merit, devoted slaves feel less deserving, spoiled slaves feel more deserving, and slaves who were already rewarded in the same day expect less - ImperatorAugustus & qwertyu12359
			if interaction_dynslave['repulse'] >= dynslave['daring']: virtue_gained += 1
			if virtue_gained > 1 and interaction_dynslave['repulse'] < dynslave['daring'] - 8: virtue_gained -= 1
			if virtue_gained > 1 and $dynslave_psy_status = 'frightened': virtue_gained -= 1
			if virtue_gained > 1 and dynslave['angst'] > 0: virtue_gained -= 1
			if success >= rise_difficulty: virtue_gained += 2
			if dynslave['moral'] = 5: virtue_gained -= 1
			if virtue_gained <= 0: virtue_gained = 0
			if virtue_gained > 5: virtue_gained = 5
			if virtue_gained >= dynslave['sin']:
				if dynslave['moral'] = 5 and dynslave['intellect'] > 3 and dynslave['selfesteem'] >= 0:
					! prior guilt can be fully canceled by new merit if the slave is fully devoted, Clever or Intelligent, and has neutral or positive self-esteem - ImperatorAugustus & qwertyu12359
					! Guilt is an awareness of punishment deserved. A fully devoted slave believes wholeheartedly that by doing what the master wants, they are doing The Right Thing.
					! A sufficiently clever, devoted slave reasons that if master chooses not to punish them when they feel guilty, master must have a good reason.
					! Instead of doubting it, they will put their whole focus into the next task and fully feel the merit they gain from it.
					dynslave['sin'] = 0
				elseif dynslave['sin'] > 0:
					! otherwise, retain some residual guilt - ImperatorAugustus & qwertyu12359
					dynslave['sin'] = 1
				end
			else
				dynslave['sin'] -= virtue_gained
				virtue_gained = 0
			end
			if virtue_gained >= dynslave['virtue']:
				dynslave['virtue'] += virtue_gained
				master_mood_rate += virtue_gained
				master_moodlet['pos_nice_slave'] = 2
				master_moodlet['neg_rebell'] = 0
			end
		!end
		if dynslave['sententia_veritas'] > 0:
			!intentionally outside the already-done-today condition
			dynslave['virtue'] += dynslave['sententia_veritas']
			dynslave['sententia_veritas'] = 0
		end
		if dynslave['virtue'] > 5: dynslave['virtue'] = 5
		if interaction_dynslave['diligence'] < (2 + dynslave['moral'] - dynslave['spoil'])/2: dynamic $sin_gained_now, 'dynslave' &! when diligence is less than half devotion offset by spoil, slave feels guilt - ImperatorAugustus
		virtue_gained = 0

	end &! end of conscious state check - ImperatorAugustus
}

$dyn_skill_rise = {
	! called from interaction_result (expects to be called after $dyn_diligence)
	! calls $sin_gained_now if diligence is zero, otherwise calls $virtue_gained_now
	! optionally, caller can set $target_skill and $target_affinity appropriately for the current activity (e.g. 'slave_rate["stamina"]' and 'sport_affinity' respectively)
	! if set by caller, increases $target_skill rate by minimum of 1, more depending on diligence, intellect, applicable learn_bonus from items
	! expects caller to set tutor_modifier (usually derived from master skill, but can be zero if slave is performing a task independently)
	! expects caller to have set $misc_bonus to a string that will expand to the learn_bonus property appropriate for the current activity (e.g., 'learn_bonus["stamina"]')
	! if set by caller, reveals $target_affinity and sets pos_job or neg_job moodlet if the slave has a corresponding positive or negative affinity
	! expects to be called with dynamic $replace($dyn_skill_rise, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist']:

		if $target_affinity ! '':
			if dynslave[$target_affinity] ! 0 and dynslave[$target_affinity + '_revealed'] = 0 and 'dynslave' ! 'assistant': dynslave[$target_affinity + '_revealed'] = 1
			if dynslave[$target_affinity] > 0: dynslave['pos_job'] = max(dynslave['pos_job'], 2)
			if dynslave[$target_affinity] < 0: dynslave['neg_job'] = max(dynslave['neg_job'], 2)
		end

		if $target_skill ! '':
			dyn_skill_rise_mod = tutor_modifier
			if dynslave['intellect'] < 2:
				dyn_skill_rise_mod -= 2
			elseif dynslave['intellect'] = 2:
				dyn_skill_rise_mod -= 1
			elseif dynslave['intellect'] = 4:
				dyn_skill_rise_mod += 1
			elseif dynslave['intellect'] = 5:
				dyn_skill_rise_mod += 2
			end
			if $misc_bonus = '':
				msg 'missing $misc_bonus for interaction (<<interaction>>)! please report this'
			else
				dynamic $replace($recalc_equipment_bonuses, 'dyn'+'slave', 'dynslave') &! refresh learn_bonus for slave (used in $misc_bonus)
				dynamic "dyn_skill_rise_mod += <<$misc_bonus>>"
			end
			skill_rise = (max(1, dyn_skill_rise_mod) * interaction_dynslave['diligence'])/4
			if $target_skill = 'stamina':
				skill_rise = skill_rise/2
				if skill_rise < 3: skill_rise = 3
				if dynslave_already_done_today['exertion'] >= dynslave['stamina']: skill_rise *= -1
				dynslave_already_done_today['exertion'] += 1
			else
				if $target_skill ! 'cowSK':
					dynslave_rate['cowSK'] -= 3 &! training any skill other than stamina decays cow training - ImperatorAugustus
				elseif dynslave['cowSK'] = 5:
					skill_rise = max(1, skill_rise - dynslave['cowSK']) &! S+ cow skill greatly impedes training other skills - ImperatorAugustus
				end
				if skill_rise < 1 or interaction_dynslave['diligence'] = 0: skill_rise = 1
			end
			dynslave_rate[$target_skill] += (skill_rise * skill_adv_mul)
		end

	end &! end of conscious state check
}

$sex_diligence = {
	phobia = 0
	if stimulating > 0 or orgastic > 0:
		phobia += sex['girl_nympo']
	end
	if shameful > 0:
		phobia += sex["girl_exhibitionism"] - shameful
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["exhibitionism_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["exhibitionism_xp"] += 1
		end
	end
	if painful > 0:
		phobia += sex["girl_masochism"] - painful
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["masochism_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["masochism_xp"] += 1
		end
	end
	if abuse > 0:
		phobia += sex["girl_abuse_attitude"] - abuse
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["abuse_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["abuse_xp"] += 1
		end
	end
	if disgusting > 0:
		phobia += sex["girl_perversion"] - disgusting
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["perversion_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["perversion_xp"] += 1
		end
	end
	if darkness > 0:
		phobia += sex["girl_darkness_attitude"] - darkness
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["darkness_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["darkness_xp"] += 1
		end
	end
	if bloody > 0:
		phobia += sex["girl_blood_attitude"] - bloody
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["blood_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["blood_xp"] += 1
		end
	end
	if fire_based > 0:
		phobia += sex["girl_fire_attitude"] - fire_based
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["fire_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["fire_xp"] += 1
		end
	end
	if water_based > 0:
		phobia += sex["girl_water_attitude"] - water_based
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["water_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["water_xp"] += 1
		end
	end
	if vermin_based > 0:
		phobia += sex["girl_vermin_attitude"] - vermin_based
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["vermin_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["vermin_xp"] += 1
		end
	end
	if deprivation > 0:
		phobia += sex["girl_deprivation_attitude"] - deprivation
		if sex_done_today[$str(sex_interaction)] = 0:
			if $sex['partner'] = '': slave["deprivation_xp"] += 1
			if $sex['partner'] = 'assistant': assistant["deprivation_xp"] += 1
		end
	end

	diligence = phobia
	if sex['bondage'] = 1: diligence += 1
	if sex['girl_mood'] > res: diligence += 1
	if sex['girl_affection'] > res: diligence += 1
	if sex['girl_love'] > res: diligence += 1
	if sex['girl_fear'] > res: diligence += 1
	if sex['girl_greed'] > res: diligence += 1
	if sex['girl_submission'] > res: diligence += 1
	if sex['girl_love'] > diligence: diligence = sex['girl_love']
	if (stimulating > 0 or orgastic > 0) and sex['girl_excitement'] > diligence: diligence = sex['girl_excitement']
	if sex['girl_spoil'] > 0: diligence -= sex['girl_spoil']
	if sex['girl_pride'] > 0: diligence -= sex['girl_pride']
	if sex['girl_mood'] < 0: diligence += sex['girl_mood'] &! addition subtracts
	if sex['girl_angst'] > 0: diligence -= 1

	if $sex['partner'] = '' and $slave_psy_status = 'broken': diligence = 0
	if $sex['partner'] = 'assistant' and $assistant_psy_status = 'broken': diligence = 0
	if sex['girl_energy'] <= 0: diligence = 0
	if diligence > 5: diligence = 5
}

$slave_energy_drop = {
	if cheat_inf_en = 0:
		slave['half_action'] += 2
		if easy_for_slave = 1: slave['half_action'] -= 1 & easy_for_slave = 0 &! clear the flag (used in interaction_result)
		if slave['half_action'] > 1: slave['energy'] -= 1 & slave['half_action'] -= 2
	end
	if slave['energy'] < -5: slave['energy'] = -5
	if slave['energy'] < 0: slave_rate['stamina'] += slave['energy']
	slave['calories'] -= 1
}

$assistant_energy_drop = {
	if cheat_inf_en = 0:
		assistant['half_action'] += 2
		if easy_for_assistant = 1: assistant['half_action'] -= 1 & easy_for_assistant = 0 &! clear the flag (used in interaction_result)
		if assistant['half_action'] > 1: assistant['energy'] -= 1 & assistant['half_action'] -= 2
	end
	if assistant['energy'] < -5: assistant['energy'] = -5
	if assistant['energy'] < 0: assistant_rate['stamina'] += assistant['energy']
	assistant['calories'] -= 1
	!calorie counting for assistant in case she switches to slave - ImperatorAugustus
}

$master_energy_drop = {
	if cheat_inf_en = 0:
		!revised bull ring effect to double actions per day instead of infinite - ImperatorAugustus
		master_half_action += iif(bull_ring_on = 1, 1, 2)
		if easy_for_master = 1: master_half_action -= 1 & easy_for_master = 0 &! clear the flag (used in interaction_result)
		if master_half_action > 1: master_energy -= 1 & master_half_action -= 2
	end
	if master_energy < -5: master_energy = -5
	if master_energy < 0: master_str_rate += master_energy
	! removed 'and bull_ring_on = 0' strength (master health) protection - ImperatorAugustus
}

$prisoner_energy_drop = {
	! added cheat_inf_en check for prisoner - ImperatorAugustus
	if cheat_inf_en = 0:
		prisoner['half_action'] += 2
		if easy_for_prisoner = 1: prisoner['half_action'] -= 1 & easy_for_prisoner = 0 &! clear the flag (used in interaction_result)
		if prisoner['half_action'] > 1: prisoner['energy'] -= 1 & prisoner['half_action'] -= 2
	end
	if prisoner['energy'] < -5: prisoner['energy'] = -5
	if prisoner['energy'] < 0: prisoner_rate['stamina'] += prisoner['energy']
	prisoner['calories'] -= 1
}

$cow_energy_drop = {
	! added cheat_inf_en check for cow - ImperatorAugustus
	if cheat_inf_en = 0:
		cow['half_action'] += 2
		if easy_for_cow = 1: cow['half_action'] -= 1 & easy_for_cow = 0 &! clear the flag (used in interaction_result)
		if cow['half_action'] > 1: cow['energy'] -= 1 & cow['half_action'] -= 2
	end
	if cow['energy'] < -5: cow['energy'] = -5
	if cow['energy'] < 0: cow_rate['stamina'] += cow['energy']
	cow['calories'] -= 1
}

$dynamic_energy_drop = {
	! added cheat_inf_en check - ImperatorAugustus
	if cheat_inf_en = 0:
		dynslave['half_action'] += 2
		if easy_for_dynslave = 1: dynslave['half_action'] -= 1 & easy_for_dynslave = 0 &! clear the flag (used in interaction_result)
		if dynslave['half_action'] > 1: dynslave['energy'] -= 1 & dynslave['half_action'] -= 2
	end
	if dynslave['energy'] < -5: dynslave['energy'] = -5
	if dynslave['energy'] < 0: dynslave_rate['stamina'] += dynslave['energy']
	dynslave['calories'] -= 1
}

$transport_energy_drop = {
	! energy drop only when traveling to a different district that is not the district where home estate is located
	! energy drop is also skipped if called with an estate name that matches the current home estate
	if city_form = city_district or (city_form/10) = city_district: exit &! at home, city_district is -1, so this is when not home and fast-traveling to where you already are
	if $quick_move_action = "go" and (city_form = estate_district[$estate] or (city_form/10) = estate_district[$estate]): exit &! fast travel/enter a district from city_form = 0
	if $args[0] = $estate: exit &! click per-decade event buttons, click empty slave avatar to go to market, click cryo button (when home capsule is rented)
	if chariot_state > CONST_INT['no_slave'] and horse_power > 0:
		horse_power -= 1
	else
		easy_for_master = 1 &! half-action or free with Bull Ring
		dynamic $master_energy_drop
	end
}

$home_sounds = {
	if sound_on = 1:
		if master_mood = 0:
			$main_sound = 'content/snd/home.wav'
		elseif master_mood > 3:
			$main_sound = 'content/snd/home_verygoodmood.wav'
		elseif master_mood > 0:
			$main_sound = 'content/snd/home_goodmood.wav'
		elseif master_mood < -3:
			$main_sound = 'content/snd/home_verybadmood.wav'
		else
			$main_sound = 'content/snd/home_badmood.wav'
		end
		play $main_sound, music_volume, 'only, loop'
		if is_home = 0: play 'content/snd/door.wav'
	end
}

$master_ejaculate = {
	if master_excitement >= 0:
		master_mood_rate += ejaculation_intensity * master_excitement
		master_moodlet['pos_satisfied'] = max(master_moodlet['pos_satisfied'], min(5, (1 + ejaculation_intensity)/2))
	end
	if debug_excitement = 1 and ejaculation_intensity > 5: msg 'ejaculation_intensity = <<ejaculation_intensity>>'
	master_excitement_rate -= ejaculation_intensity*10
	if master_excitement >= 0: master_libido_rate += ejaculation_intensity
	if master_excitement < 0:  master_libido_rate -= ejaculation_intensity
	gs '$calculate_attributes', 1 &! update excitement and libido (1 = skip mood update to not interfere with next_day mood checks when invoked via alarm rule - ImperatorAugustus)
}

$house_cleaning = {
	house_mess = 0
	if house_mess_rate >= 10: house_mess = 1
	if house_mess_rate >= 20: house_mess = 2
	if house_mess_rate >= 40: house_mess = 3
	if house_mess_rate >= 60: house_mess = 4
	if house_mess_rate >= 80: house_mess = 5
}

$dyn_stamina_rise = {
	! expects to be called with dynamic $replace($dyn_stamina_rise, 'dyn'+'slave', 'a slave instance variable'), # of calories, # of stamina points
	if dynslave_state = CONST_INT['slave_exist']:

		dynslave['calories'] -= args[0]
		if dynslave_already_done_today['exertion'] < dynslave['stamina']:
			dynslave_rate['stamina'] += min(interaction_dynslave['diligence'], args[1])
		else
			dynslave_rate['stamina'] -= min(interaction_dynslave['diligence'], args[1])
		end
		dynslave_already_done_today['exertion'] += 1

	end &! end of conscious state check
}

!Strange stamina gain fixed - crushboss
$dyn_slave_damaged = {
	! expects to be called with dynamic $replace($dyn_slave_damaged, 'dyn'+'slave', 'a slave instance variable')
	! caller can optionally set 'damage' global before calling, resulting in wounds if it exceeds the stamina of the slave
	! additional global flags 'bruising' and 'scarification' can be set to 1 by the caller if those impacts are desired
	if dynslave_state > CONST_INT['no_slave']:

		if damage > dynslave['stamina']: dynslave_rate['wounds'] += damage
		damage += dynslave['sensitivity'] + min(dynslave['wounds'], dynslave['hygiene']) - dynslave['stamina']
		if damage < 0: damage = 0
		dynslave_rate['stamina'] -= damage
		if bruising = 1:
			dynslave_rate['bruises'] += damage * (8 - dynslave['stamina']) &! slaves with lower endurance are more susceptible to bruising - ImperatorAugustus
			if dynslave_rate['bruises'] < cont_atr_threshold[1]: dynslave_rate['bruises'] = cont_atr_threshold[1] &! always reach at least first visible level
		end
		if scarification = 1: dynslave_rate['scars'] += damage
		damage = 0

	end &! end of conscious or fainted state check
}

$slave_fights_back = {
	killvar '$play_sound'
	$play_sound[1] = $cane_sound
	if master_str < 4: master_str_rate += 2
	dynamic $sin_gained_now, 'slave'
	msg '   Your slave rebels against you. Prepare to fight…'
	количество_врагов = 1
	$враг[1] = 'воспитуемая'
	slave['beaten'] = 1
	slave['beaten_ever'] = 1
	slave['calories'] -= 5
	slave_rate['stamina'] += 2
	$fight_return = 'menu_form'
	combatant = 0 &! master is in the defending slot
	gt 'начать_бой'
}

$dyn_slave_forced = {
	! expects to be called with dynamic $replace($dyn_slave_forced, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state = CONST_INT['slave_exist']:

		killvar '$play_sound'
		$play_sound[1] = $cane_sound
		if master_str < 4: master_str_rate += 1
		if is_kid = 1 and dynslave['age'] = CONST_INT['loli_age']:
			msg '   <<$dynslave_name>> rebels, forcing you to resort to brute force. You easily overcome the loli’s resistance. It is so much easier forcing girls that are smaller than you.'
			if no_loli = 2 and dynslave['boobs'] = 0:  msg '   <<$dynslave_name>> rebels, forcing you to resort to brute force. You easily overcome the little girl’s resistance. Forcing girls that are so much younger than you is easy.'
		else
			msg '   <<$dynslave_name>> rebels, forcing you to resort to brute force. Too weak or intimidated to put up any real resistance, the brief struggle earns her a few new bruises.'
		end
		dynslave['neg_forced'] = dynslave['ego']
		dynslave['virtue'] = 0
		if dynslave['sin'] = 0: dynamic $sin_gained_now, 'dynslave'
		dynslave['beaten'] = 1
		dynslave['beaten_ever'] = 1
		dynslave['calories'] -= 1
		damage = dynslave['stamina'] + master_str - master_fighter &! a skilled fighter can control his strength to reduce damage
		if damage > 5: damage = 5 & scarification = 1
		if damage > 0: gs '$mood_drop', 'dynslave', damage
		bruising = 1
		dynamic $replace($dyn_slave_damaged, 'dyn'+'slave', 'dynslave') &! protect from earlier replace

	end &! end of conscious state check
}

$dyn_rape_effects = {
	! expects to be called with dynamic $replace($dyn_rape_effects, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		rape_fear = max(0, (1 - dynslave['arousal']/5) + (dynslave['pride']*2 + dynslave['ego']*2 + dynslave['intellect'] + dynslave['temper'] - dynslave['moral']*4))
		dynslave['sin'] = 0 &! being raped clears guilt
		if dynslave['abuse_attitude'] = -1 or dynslave['nymphomania'] < 0: rape_fear *= 2
		if dynslave['abuse_attitude'] = 1 or dynslave['nymphomania'] > 0: rape_fear /= 2
		if dynslave['abuse_attitude'] = 2 or dynslave['moral'] = 5: rape_fear = 0 &! zero for psi-masochists or fully devoted slaves
		if rape_fear > 0:
			dynslave_rate['instinct'] += 2*(master_str + master_penetration) &! B+ strength and C- penetration will raise taming by 10 pts; S+/S+ will raise taming by 20 pts
			if dynslave['pride'] > 2: dynslave_rate['pride'] -= dynslave['pride']*4 &! 4-5 repetitions to drop maxed pride for non-virgin (-80 rate threshold, rate can go up to +10)
			dynslave_rate['moral'] -= dynslave['moral']*10 &! rape reduces devotion unless fully devoted (rape_fear = 0 does not reach this code)
			if dynslave['angst'] = 5: dynslave_rate['ego'] -= 2 * (1 + dynslave['sensitivity']) & dynslave_rate['temper'] -= 4 * (1 + dynslave['sensitivity']) &! drain stats directly when angst is already maxed - ImperatorAugustus
			dynslave['angst'] = max(min(5, dynslave['angst'] + 2), dynslave['sensitivity'] - 1) &! angst will drain nature and temperament; increase by 2 or to empathy level - 1 if higher
			dynslave_rate['angst'] = max(dynslave_rate['angst'], indep_atr_max_threshold[dynslave['angst']] / 2) &! set at least half-way to next level
			dynslave_rate['mood'] -= dynslave['temper']*6 &! -30 mood rate with S+ temperament (devotion cannot exceed 4 here), combines with moodlet
			dynslave['neg_raped'] += dynslave['sensitivity'] &! moodlet drops mood by 1 (equivalent to -10 mood rate) if not already applied
			gs '$mood_drop', 'dynslave', dynslave['sensitivity'] &! reduce magnitude of any positive moodlets
		end

	end &! end of existence check
}

$dyn_slave_bathed = {
	! clear hygiene and perfume and set mood
	! expects to be called with dynamic $replace($dyn_slave_bathed, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		dynslave_rate['mood'] += dynslave['hygiene']/10 &! max of +2 mood with 200 hygiene - ImperatorAugustus
		dynslave_rate['hygiene'] = 0
		dynslave['hygiene'] = 0
		dynslave['pos_slave_clean'] = 1
		if dynslave['perfume'] = 1: dynslave['perfume'] = 0
		house_mess_rate += 1

	end &! end of conscious or fainted state check
}

!CHARIOT RACE
$damage_frame = {
	if boards >= frame:
		boards -= 1
	else
		frame -= 1
	end
}

$damage_wheels = {
	if wheels >= chassis:
		wheels -= 1
	else
		chassis -= 1
	end
}

$chariot_crash = {
	if chariot['inertia'] > 1:
		frame = 0
	else
		dynamic $damage_frame
	end
}

$pony_death = {
	chariot['pony_health'] = 0
}

!TRINITY (BATTLE ENGINE)

$в_боевое_меню = {
	gs 'боевое_меню'
	gt 'боевой_интерфейс'
}

!from location 'сменить_оружие'
$сменить_вторичное = {
	gt 'боевой_интерфейс'
}
$убрать_основное = {
	$оружие = 'безоружный'
	gs 'боевое_меню'
	gt 'боевой_интерфейс'
}
$убрать_вторичное = {
	$вторичный = ''
	gs 'боевое_меню'
	gt 'боевой_интерфейс'
}

!Dual Wield system - Primary Weapon - overhauled by crushboss
$primary_weapon = {
	if no_wpn['за_спиной'] = 1:
	!Two-Handed Back Weapon
		$оружие = $за_спиной
		$вторичный = ''
		if combatant = 0: $за_спиной = $master_back_wpn & $master['prev_secondary_wpn'] = ''
		if combatant = 1: $за_спиной = $slave['back_wpn'] & $slave['prev_secondary_wpn'] = ''
		if combatant = 2: $за_спиной = $assistant['back_wpn'] & $assistant['prev_secondary_wpn'] = ''
	elseif no_wpn['справа'] = 1:
	!Right Weapon
		$оружие = $справа
		if combatant = 0: $справа = $master_right_wpn
		if combatant = 1: $справа = $slave['right_wpn']
		if combatant = 2: $справа = $assistant['right_wpn']
	elseif no_wpn['слева'] = 1:
	!Left Weapon
		$оружие = $слева
		if combatant = 0: $слева = $master_left_wpn
		if combatant = 1: $слева = $slave['left_wpn']
		if combatant = 2: $слева = $assistant['left_wpn']
	elseif no_wpn['предплечье'] = 1:
	!Bracer Weapon (arm)
		$оружие = $предплечье
		if combatant = 0: $предплечье = $master_arm_wpn
		if combatant = 1: $предплечье = $slave['arm_wpn']
		if combatant = 2: $предплечье = $assistant['arm_wpn']
	elseif no_wpn['в_сапоге'] = 1:
	!Boot Weapon (leg)
		$оружие = $в_сапоге
		if combatant = 0: $в_сапоге = $master_leg_wpn
		if combatant = 1: $в_сапоге = $slave['leg_wpn']
		if combatant = 2: $в_сапоге = $assistant['leg_wpn']
	end
	!Remember the previous primary weapon
	if $оружие ! '':
		if combatant = 0: $master['prev_primary_wpn'] = $оружие
		if combatant = 1: $slave['prev_primary_wpn'] = $оружие
		if combatant = 2: $assistant['prev_primary_wpn'] = $оружие
	end
}

!Dual Wield system - Secondary Weapon - overhauled by crushboss
$secondary_weapon = {
	if no_wpn['слева'] = 2:
	!Left Weapon
		$вторичный = $слева
		if combatant = 0: $слева = $master_left_wpn
		if combatant = 1: $слева = $slave['left_wpn']
		if combatant = 2: $слева = $assistant['left_wpn']
	elseif no_wpn['справа'] = 2:
	!Right Weapon
		$вторичный = $справа
		if combatant = 0: $справа = $master_right_wpn
		if combatant = 1: $справа = $slave['right_wpn']
		if combatant = 2: $справа = $assistant['right_wpn']
	elseif no_wpn['предплечье'] = 2:
	!Bracer Weapon (arm)
		$вторичный = $предплечье
		if combatant = 0: $предплечье = $master_arm_wpn
		if combatant = 1: $предплечье = $slave['arm_wpn']
		if combatant = 2: $предплечье = $assistant['arm_wpn']
	elseif no_wpn['в_сапоге'] = 2:
	!Boot Weapon (leg)
		$вторичный = $в_сапоге
		if combatant = 0: $в_сапоге = $master_leg_wpn
		if combatant = 1: $в_сапоге = $slave['leg_wpn']
		if combatant = 2: $в_сапоге = $assistant['leg_wpn']
	end
	!Remember the previous secondary weapon
	if $вторичный ! '':
		if combatant = 0: $master['prev_secondary_wpn'] = $вторичный
		if combatant = 1: $slave['prev_secondary_wpn'] = $вторичный
		if combatant = 2: $assistant['prev_secondary_wpn'] = $вторичный
	end
}

!Use Previous Weapon Configuration Option - crushboss
$previous_weapon = {
	!Primary
	if $оружие = '' and a = 1:
		if combatant = 0 and ($master_back_wpn = $master['prev_primary_wpn'] or _
							$master_left_wpn = $master['prev_primary_wpn'] or _
							$master_right_wpn = $master['prev_primary_wpn'] or _
							$master_arm_wpn = $master['prev_primary_wpn'] or _
							$master_leg_wpn = $master['prev_primary_wpn']): $оружие = $master["prev_primary_wpn"]
		if combatant = 1 and ($slave['back_wpn'] = $slave['prev_primary_wpn'] or _
							$slave['left_wpn'] = $slave['prev_primary_wpn'] or _
							$slave['right_wpn'] = $slave['prev_primary_wpn'] or _
							$slave['arm_wpn'] = $slave['prev_primary_wpn'] or _
							$slave['leg_wpn'] = $slave['prev_primary_wpn']): $оружие = $slave["prev_primary_wpn"]
		if combatant = 2 and ($assistant['back_wpn'] = $assistant['prev_primary_wpn'] or _
							$assistant['left_wpn'] = $assistant['prev_primary_wpn'] or _
							$assistant['right_wpn'] = $assistant['prev_primary_wpn'] or _
							$assistant['arm_wpn'] = $assistant['prev_primary_wpn'] or _
							$assistant['leg_wpn'] = $assistant['prev_primary_wpn']): $оружие = $assistant["prev_primary_wpn"]
	end

	! Secondary
	if $вторичный = '' and a = 1:
		if combatant = 0 and ($master_left_wpn = $master["prev_secondary_wpn"] or _
							$master_right_wpn = $master["prev_secondary_wpn"] or _
							$master_arm_wpn = $master["prev_secondary_wpn"] or _
							$master_leg_wpn = $master["prev_secondary_wpn"]): $вторичный = $master["prev_secondary_wpn"]
		if combatant = 1 and ($slave['left_wpn'] = $slave["prev_secondary_wpn"] or _
							$slave['right_wpn'] = $slave["prev_secondary_wpn"] or _
							$slave['arm_wpn'] = $slave["prev_secondary_wpn"] or _
							$slave['leg_wpn'] = $slave["prev_secondary_wpn"]): $вторичный = $slave["prev_secondary_wpn"]
		if combatant = 2 and ($assistant['left_wpn'] = $assistant["prev_secondary_wpn"] or _
							$assistant['right_wpn'] = $assistant["prev_secondary_wpn"] or _
							$assistant['arm_wpn'] = $assistant["prev_secondary_wpn"] or _
							$assistant['leg_wpn'] = $assistant["prev_secondary_wpn"]): $вторичный = $assistant["prev_secondary_wpn"]
	end
}

$взять_оружие_за_спиной = {
	if $класс_оружия[$за_спиной]!'вторичное_оружие':
		if $за_спиной ! 'вторичный':
			$оружие = $за_спиной
			if $класс_оружия[$за_спиной] = 'тяжелое_оружие': $вторичный = ''
			if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$за_спиной]>>'
			if nogoto = 0: gt 'ход_противников'
		end
	end
}
$взять_оружие_слева = {
	if $класс_оружия[$слева]!'вторичное_оружие':
		if $слева ! $вторичный:
			$оружие = $слева
			if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$слева]>>'
			if nogoto = 0: gt 'ход_противников'
		end
	end
}
$взять_оружие_справа = {
	if $класс_оружия[$справа]!'вторичное_оружие':
		if $справа ! $вторичный:
			$оружие = $справа
			if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$справа]>>'
			if nogoto = 0: gt 'ход_противников'
		end
	end
}
$взять_оружие_предплечье = {
	if $класс_оружия[$предплечье]!'вторичное_оружие':
		if $предплечье ! $вторичный:
			$оружие = $предплечье
			if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$предплечье]>>'
			if nogoto = 0: gt 'ход_противников'
		end
	end
}
$взять_оружие_в_сапоге = {
	if $класс_оружия[$в_сапоге]!'вторичное_оружие':
		if $в_сапоге ! $вторичный:
			$оружие = $в_сапоге
			if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$в_сапоге]>>'
			if nogoto = 0: gt 'ход_противников'
		end
	end
}
!TODO: лишние endы, надо проверить
$взять_вторичный_в_сапоге = {
	$вторичный = $в_сапоге
	if $класс_оружия[$оружие] = 'тяжелое_оружие': $оружие = ''
	if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$в_сапоге]>>'
	if nogoto = 0: gt 'ход_противников'
}
$взять_вторичный_предплечье = {
	$вторичный = $предплечье
	if $класс_оружия[$оружие] = 'тяжелое_оружие': $оружие = ''
	if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$предплечье]>>'
	if nogoto = 0: gt 'ход_противников'
}
$взять_вторичный_справа = {
	if $класс_оружия[$справа] ! 'оружие':
		$вторичный = $справа
		if $класс_оружия[$оружие] = 'тяжелое_оружие': $оружие = ''
		if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$справа]>>'
		if nogoto = 0: gt 'ход_противников'
	end
end
}
$взять_вторичный_слева = {
	if $класс_оружия[$слева] ! 'оружие':
		$вторичный = $слева
		if $класс_оружия[$оружие] = 'тяжелое_оружие': $оружие = ''
		if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$слева]>>'
		if nogoto = 0: gt 'ход_противников'
	end
end
}
$взять_вторичный_за_спиной = {
	if $класс_оружия[$за_спиной] ! 'оружие' and $класс_оружия[$за_спиной] ! 'тяжелое_оружие':
		$вторичный = $за_спиной
		if $класс_оружия[$оружие] = 'тяжелое_оружие': $оружие = ''
		if nogoto = 0: $действия_игрока = 'You pick up the <<$item_name[$за_спиной]>>'
		if nogoto = 0: gt 'ход_противников'
	end
end
}

$сменить_защиту = {
	if $защита[0] = 'контратака': $защита[0] = 'блок' & gt $curloc
	if $защита[0] = 'уклонение': $защита[0] = 'контратака' & gt $curloc
	if $защита[0] = 'блок': $защита[0] = 'уклонение' & gt $curloc
}

!To show the effects imposed on the Player
$слабость_игрока = {
	if слабость > 0: $плохие_эффекты_игрока += "WEAKNESS[<<слабость>>]
"
}

$скованность_игрока = {
	if скованность > 0: $плохие_эффекты_игрока += "STIFFNESS[<<скованность>>]
"
}

$боль_игрока = {
	if боль > 0: $плохие_эффекты_игрока += "SEVERE PAIN[<<боль>>]

"
}

$шаткость_игрока = {
	if шаткость > 0: $плохие_эффекты_игрока += "UNSTEADINESS[<<шаткость>>]
"
}

$ошеломление_игрока = {
	if ошеломление > 0: $плохие_эффекты_игрока += "STUNNED[<<ошеломление>>]
"
}

$рассеянность_игрока = {
	if рассеянность > 0: $плохие_эффекты_игрока += "DISTRACTION[<<рассеянность>>]
"
}

$бешенство_игрока = {
	if бешенство > 0: $хорошие_эффекты_игрока += "FURY[<<бешенство>>]
"
}

$разгон_игрока = {
	if разгон > 0: $хорошие_эффекты_игрока += "ACCELERATION[<<разгон>>]
"
}

$меткость_игрока = {
	if меткость > 0: $хорошие_эффекты_игрока += "PRECISION[<<меткость>>]

"
}

$адреналин_игрока = {
	if адреналин > 0: $хорошие_эффекты_игрока += "ADRENALINE[<<адреналин>>]
"
}

$верткость_игрока = {
	if верткость > 0: $хорошие_эффекты_игрока += "EVASION[<<верткость>>]
"
}

$внимание_игрока = {
	if внимание > 0: $хорошие_эффекты_игрока += "ATTENTION[<<внимание>>]
"
}

!To show the effects imposed to the current enemy

$слабость_противника = {
	if слабость[текущий] > 0: $плохие_эффекты_проивника += "WEAKNESS[<<слабость[текущий]>>]
"
}
$скованность_противника = {
	if скованность[текущий] > 0: $плохие_эффекты_проивника += "STIFFNESS[<<скованность[текущий]>>]
"
}
$боль_противника = {
	if боль[текущий] > 0: $плохие_эффекты_проивника += "SEVERE PAIN[<<боль[текущий]>>]
"
}
$шаткость_противника = {
	if шаткость[текущий] > 0: $плохие_эффекты_проивника += "UNSTEADINESS[<<шаткость[текущий]>>]
"
}
$ошеломление_противника = {
	if ошеломление[текущий] > 0: $плохие_эффекты_проивника += "STUNNED[<<ошеломление[текущий]>>]
"
}
$рассеянность_противника = {
	if рассеянность[текущий] > 0: $плохие_эффекты_проивника += "DISTRACTION[<<рассеянность[текущий]>>]
"
}

$бешенство_противника = {
	if бешенство[текущий] > 0: $хорошие_эффекты_противника += "[<<бешенство[текущий]>>]FURY
"
}
$разгон_противника = {
	if разгон[текущий] > 0: $хорошие_эффекты_противника += "[<<разгон[текущий]>>]ACCELERATION
"
}
$меткость_противника = {
	if меткость[текущий] > 0: $хорошие_эффекты_противника += "[<<меткость[текущий]>>]PRECISION
"
}
$адреналин_противника = {
	if адреналин[текущий] > 0: $хорошие_эффекты_противника += "[<<адреналин[текущий]>>]ADRENALINE
"
}
$верткость_противника = {
	if верткость[текущий] > 0: $хорошие_эффекты_противника += "[<<верткость[текущий]>>]EVASION
"
}
$внимание_противника = {
	if внимание[текущий] > 0: $хорошие_эффекты_противника += "[<<внимание[текущий]>>]ATTENTION
"
}

!attacks
$первое_действие = {
	gt 'атака_игрока',1
}

$второе_действие = {
	gt 'атака_игрока',2
}
$атака_второй_рукой = {
	gt 'атака_игрока',31
}

$пинок = {
	gt 'атака_игрока',11
}
$толчок = {
	gt 'атака_игрока',12
}
$подсечка = {
	gt 'атака_игрока',13
}

!Used to be named $суперудар_1 with variable суперудар_сделан[1] = 1.  Somewhere in the code it was setting the variable to 1
!Not a pretty fix but it works with new function and variable names without issues - crushboss
$суперудар_11 = {
	суперудар_сделан[11] = 1
	gt 'атака_игрока',21
}
$суперудар_12 = {
	суперудар_сделан[12] = 1
	gt 'атака_игрока',22
}
$суперудар_13 = {
	суперудар_сделан[13] = 1
	gt 'атака_игрока',23
}
$суперудар_14 = {
	суперудар_сделан[14] = 1
	gt 'атака_игрока',24
}
$суперудар_15 = {
	суперудар_сделан[15] = 1
	gt 'атака_игрока',25
}
$суперудар_16 = {
	суперудар_сделан[16] = 1
	gt 'атака_игрока',26
}
$суперудар_17 = {
	суперудар_сделан[17] = 1
	gt 'атака_игрока',27
}
$суперудар_18 = {
	суперудар_сделан[18] = 1
	gt 'атака_игрока',28
}
$суперудар_22 = {
	суперудар_сделан[22] = 1
	gt 'атака_игрока',32
}
$суперудар_23 = {
	суперудар_сделан[23] = 1
	gt 'атака_игрока',33
}
$суперудар_24 = {
	суперудар_сделан[24] = 1
	gt 'атака_игрока',34
}
$суперудар_25 = {
	суперудар_сделан[25] = 1
	gt 'атака_игрока',35
}

$вернуться_в_корень = {
	gs 'боевое_меню'
	gt 'боевой_интерфейс'
}

!Switching between enemies
$переключатель_врагов[1] = {
	if враг[1] = 1:
		$панель_переключений += '[1] '
		!bugfix: there was a double gt in the line above -ImperatorAugustus
	else
		$панель_переключений += '[1] '
	end
}
$переключатель_врагов[2] = {
	if враг[2] = 1:
		$панель_переключений += '[2] '
	else
		$панель_переключений += '[2] '
	end
}
$переключатель_врагов[3] = {
	if враг[3] = 1:
		$панель_переключений += '[3] '
	else
		$панель_переключений += '[3] '
	end
}
$переключатель_врагов[4] = {
	if враг[4] = 1:
		$панель_переключений += '[4] '
	else
		$панель_переключений += '[4] '
	end
}
$переключатель_врагов[5] = {
	if враг[5] = 1:
		$панель_переключений += '[5]'
	else
		$панель_переключений += '[5]'
	end
}

$show_item_description_and_image = {
	if $args[0] ! '' and $args[0] ! 'пусто' and $item_description[$args[0]] ! '':
		dynamic "$info_text = '   <<$strfind($item_description[$args[0]], {([ ]+Price: [0-9]+ sparks[^<]*[^ ]+)?([ ]+)?(.*)}, 3)>>'"
		if $item_demo[$args[0]] ! '':
			$info_text = '<img style="float:left;object-fit:cover;margin-right:10px;max-height:135px;" src="content\pic\<<$item_demo[$args[0]]>>.png">' + iif(len($info_text) < 363, $info_text, '
'+$info_text+'
')
		end
	end
}

$master_armor_list = {
	slot = 1
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_armor
	if $master_armor ! '' and $master_armor ! 'без_брони': $equip_choice += '- remove armor -
'
	if комбез > 0: $equip_choice += 'Aramid Suit [<<комбез>>]
'
	if кожан > 0: $equip_choice += 'Leather Armor [<<кожан>>]
'
	if эльчуга > 0: $equip_choice += 'Elven Chainmail [<<эльчуга>>]
'
	if ячуга > 0: $equip_choice += 'Yatserin Mail [<<ячуга>>]
'
	if полудоспех > 0: $equip_choice += 'Combined Armor [<<полудоспех>>]
'
	if плейт > 0: $equip_choice += 'Gothic Plate [<<плейт>>]
'
	if кольчуга > 0: $equip_choice += 'Mithril Mail [<<кольчуга>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_wpn_list_large = {
	slot = 2
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_back_wpn
	if $master_back_wpn ! '' and $master_back_wpn ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if фламберг > 0: $equip_choice += 'Flamberge [<<фламберг>>]
'
	if нагината > 0: $equip_choice += 'Naginata [<<нагината>>]
'
	if моргенштерн > 0: $equip_choice += 'Morningstar [<<моргенштерн>>]
'
	if посох_огня > 0: $equip_choice += 'Dragon Fire Staff Relic [<<посох_огня>>]
'
	if грейтекс > 0: $equip_choice += 'Greataxe [<<грейтекс>>]
'
	if бита > 0: $equip_choice += 'Baseball Bat [<<бита>>]
'
	if скотобой > 0: $equip_choice += 'Cattle Prod [<<скотобой>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_wpn_list = {
	slot = 3
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_left_wpn
	if $master_left_wpn ! '' and $master_left_wpn ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$master_wpn_list_2 = {
	slot = 4
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_right_wpn
	if $master_right_wpn ! '' and $master_right_wpn ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$master_wpn_list_small = {
	slot = 5
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_arm_wpn
	if $master_arm_wpn ! '' and $master_arm_wpn ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_wpn_list_small_2 = {
	slot = 6
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_leg_wpn
	if $master_leg_wpn ! '' and $master_leg_wpn ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

!$info_text - displays a hint when equipped
$master_cloth_list = {
	slot = 7
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_cloth
	if $master_cloth ! 'man_rugs': $equip_choice += 'Worn Clothes
'
	if comfy_robes > 0:            $equip_choice += 'Housecoat
'
	if fancy_suit > 0:             $equip_choice += 'Fashionable Attire
'
	if regal_suit > 0:             $equip_choice += 'Noble Regalia
'
	if formal_suit > 0:            $equip_choice += 'Formal Suit
'
	if aketon > 0:                 $equip_choice += 'Aketon
'
	if livery > 0:                 $equip_choice += 'Livery
'
	if medic_robes > 0:            $equip_choice += 'Medical Gown
'
	if wizard_robes > 0:           $equip_choice += 'Wizard Robes
'
	if $equip_choice = '':         $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_head_list = {
	slot = 8
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_head_gear
	if $item_name[$master_head_gear] ! '' and $item_name[$master_head_gear] ! '-': $equip_choice += '- Remove headgear -
'
	if raven_crown > 0: $equip_choice += 'Raven Crown
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_ears_list = {
	slot = 9
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_earring
	if $item_name[$master_earring] ! '' and $item_name[$master_earring] ! '-': $equip_choice += '- Remove earring -
'
	if chimera_earring > 0: $equip_choice += 'Chimaera’s Gem
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_neck_list = {
	slot = 10
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_amulet
	if $item_name[$master_amulet] ! '' and $item_name[$master_amulet] ! '-': $equip_choice += '- Remove amulet -
'
	if snake_amulet > 0: $equip_choice += 'Snake Talisman
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$master_ring_list = {
	slot = 11
	$equip_choice = ''
	dynamic $show_item_description_and_image, $master_ring
	if $item_name[$master_ring] ! '' and $item_name[$master_ring] ! '-': $equip_choice += '- Take off ring -
'
	if bull_ring > 0: $equip_choice += 'Bull Ring
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

! slave Stuff
$slave_armor_list = {
	slot = 20
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["armor"]
	if $slave["armor"] ! '' and $slave["armor"] ! 'без_брони': $equip_choice += '- remove armor-
'
	if комбез > 0: $equip_choice += 'Aramid Suit [<<комбез>>]
'
	if кожан > 0: $equip_choice += 'Leather Armor [<<кожан>>]
'
	if эльчуга > 0: $equip_choice += 'Elven Chainmail [<<эльчуга>>]
'
	if ячуга > 0: $equip_choice += 'Yatserin Mail [<<ячуга>>]
'
	if полудоспех > 0: $equip_choice += 'Combined Armor [<<полудоспех>>]
'
	if плейт > 0: $equip_choice += 'Gothic Plate [<<плейт>>]
'
	if кольчуга > 0: $equip_choice += 'Mithril Mail [<<кольчуга>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_wpn_list_large = {
	slot = 21
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["back_wpn"]
	if $item_name[$slave["back_wpn"]] ! '' and $item_name[$slave["back_wpn"]] ! '-': $equip_choice += '- unequip weapon -
'
	if фламберг > 0: $equip_choice += 'Flamberge [<<фламберг>>]
'
	if нагината > 0: $equip_choice += 'Naginata [<<нагината>>]
'
	if моргенштерн > 0: $equip_choice += 'Morningstar [<<моргенштерн>>]
'
	if грейтекс > 0: $equip_choice += 'Greataxe [<<грейтекс>>]
'
	if бита > 0: $equip_choice += 'Baseball Bat [<<бита>>]
'
	if скотобой > 0: $equip_choice += 'Cattle Prod [<<скотобой>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_wpn_list = {
	slot = 22
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["left_wpn"]
	if $slave["left_wpn"] ! '' and $slave["left_wpn"] ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$slave_wpn_list_2 = {
	slot = 23
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["right_wpn"]
	if $slave["right_wpn"] ! '' and $slave["right_wpn"] ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$slave_cloth_list = {
	slot = 24
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["cloth"]
	if $item_name[$slave["cloth"]] ! '' and $item_name[$slave["cloth"]] ! '-' and $item_name[$slave["cloth"]] ! 'Naked': $equip_choice += '- strip naked -
'
	if slave_inventory['common_apron'] > 0 or inventory['common_apron'] > 0: $equip_choice += '<<$item_name["common_apron"]>>
'
	if slave_inventory['maid_dress'] > 0 or inventory['maid_dress'] > 0: $equip_choice += '<<$item_name["maid_dress"]>>
'
	if slave_inventory['nurse_dress'] > 0 or inventory['nurse_dress'] > 0: $equip_choice += '<<$item_name["nurse_dress"]>>
'
	if slave_inventory['sailor_foku'] > 0 or inventory['sailor_foku'] > 0: $equip_choice += '<<$item_name["sailor_foku"]>>
'
	if slave_inventory['enchanter_robe'] > 0 or inventory['enchanter_robe'] > 0: $equip_choice += '<<$item_name["enchanter_robe"]>>
'
	if slave_inventory['leotard'] > 0 or inventory['leotard'] > 0: $equip_choice += '<<$item_name["leotard"]>>
'
	if slave_inventory['chainmail_bikini'] > 0 or inventory['chainmail_bikini'] > 0: $equip_choice += '<<$item_name["chainmail_bikini"]>>
'
	if slave_inventory['ukata'] > 0 or inventory['ukata'] > 0: $equip_choice += '<<$item_name["ukata"]>>
'
	if slave_inventory['sun_dress'] > 0 or inventory['sun_dress'] > 0: $equip_choice += '<<$item_name["sun_dress"]>>
'
	if slave_inventory['laced_underwear'] > 0 or inventory['laced_underwear'] > 0: $equip_choice += '<<$item_name["laced_underwear"]>>
'
	if slave_inventory['cocktail_dress'] > 0 or inventory['cocktail_dress'] > 0: $equip_choice += '<<$item_name["cocktail_dress"]>>
'
	if slave_inventory['rubber_dress'] > 0 or inventory['rubber_dress'] > 0: $equip_choice += '<<$item_name["rubber_dress"]>>
'
	if slave_inventory['bellydance'] > 0 or inventory['bellydance'] > 0: $equip_choice += '<<$item_name["bellydance"]>>
'
	if slave_inventory['leather_corset'] > 0 or inventory['leather_corset'] > 0: $equip_choice += '<<$item_name["leather_corset"]>>
'
	if slave_inventory['rich_dress'] > 0 or inventory['rich_dress'] > 0: $equip_choice += '<<$item_name["rich_dress"]>>
'
	if slave_inventory['wedding_dress'] > 0 or inventory['wedding_dress'] > 0: $equip_choice += '<<$item_name["wedding_dress"]>>
'
	if slave_inventory['anal_tail'] > 0 or inventory['anal_tail'] > 0: $equip_choice += '<<$item_name["anal_tail"]>>
'
	if slave_inventory['cow_gear'] > 0 or inventory['cow_gear'] > 0: $equip_choice += '<<$item_name["cow_gear"]>>
'
	if slave_inventory['petsuit'] > 0 or inventory['petsuit'] > 0: $equip_choice += '<<$item_name["petsuit"]>>
'
	if slave_inventory['deprivation_suit'] > 0 or inventory['deprivation_suit'] > 0: $equip_choice += '<<$item_name["deprivation_suit"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_head_list = {
	slot = 25
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["headband"]
	if $item_name[$slave["headband"]] ! '' and $item_name[$slave["headband"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['hijab'] > 0 or inventory['hijab'] > 0: $equip_choice += '<<$item_name["hijab"]>>
'
	if slave_inventory['crown_of_thorns'] > 0 or inventory['crown_of_thorns'] > 0: $equip_choice += '<<$item_name["crown_of_thorns"]>>
'
	if slave_inventory['plain_tiara'] > 0 or inventory['plain_tiara'] > 0: $equip_choice += '<<$item_name["plain_tiara"]>>
'
	if slave_inventory['incrusted_tiara'] > 0 or inventory['incrusted_tiara'] > 0: $equip_choice += '<<$item_name["incrusted_tiara"]>>
'
	if slave_inventory['plain_headband'] > 0 or inventory['plain_headband'] > 0: $equip_choice += '<<$item_name["plain_headband"]>>
'
	if slave_inventory['glasses'] > 0 or inventory['glasses'] > 0: $equip_choice += '<<$item_name["glasses"]>>
'
	if slave_inventory['nekomimi'] > 0 or inventory['nekomimi'] > 0: $equip_choice += '<<$item_name["nekomimi"]>>
'
	if slave_inventory['hairnet'] > 0 or inventory['hairnet'] > 0: $equip_choice += '<<$item_name["hairnet"]>>
'
	if slave_inventory['exotic_wig'] > 0 or inventory['exotic_wig'] > 0: $equip_choice += '<<$item_name["exotic_wig"]>>
'
	if slave_inventory['pony_plume'] > 0 or inventory['pony_plume'] > 0: $equip_choice += '<<$item_name["pony_plume"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_ears_list = {
	slot = 26
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["earrings"]
	if $item_name[$slave["earrings"]] ! '' and $item_name[$slave["earrings"]] ! '-': $equip_choice += '- remove -
'
	if slave["ear_piercing"] = 0:
		$equip_choice += 'Ears are not pierced
'
		if slave_inventory['incrusted_earrings'] > 1 or inventory['incrusted_earrings'] > 1: $equip_choice += 'Gemstone Clip-ons
'
	else
		if slave_inventory['plain_earrings'] > 1 or inventory['plain_earrings'] > 1: $equip_choice += '<<$item_name["plain_earrings"]>>s
'
		if slave_inventory['incrusted_earrings'] > 1 or inventory['incrusted_earrings'] > 1: $equip_choice += '<<$item_name["incrusted_earrings"]>>s
'
		if slave_inventory['heavy_gauge_rings'] > 1 or inventory['heavy_gauge_rings'] > 1: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>s
'
	end
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_neck_list = {
	slot = 27
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["collar"]
	if $item_name[$slave["collar"]] ! '' and $item_name[$slave["collar"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['leather_collar'] > 0 or inventory['leather_collar'] > 0: $equip_choice += '<<$item_name["leather_collar"]>>
'
	if slave_inventory['steel_collar'] > 0 or inventory['steel_collar'] > 0: $equip_choice += '<<$item_name["steel_collar"]>>
'
	if slave_inventory['spiked_collar'] > 0 or inventory['spiked_collar'] > 0: $equip_choice += '<<$item_name["spiked_collar"]>>
'
	if slave_inventory['dog_collar'] > 0 or inventory['dog_collar'] > 0: $equip_choice += '<<$item_name["dog_collar"]>>
'
	if slave_inventory['golden_collar'] > 0 or inventory['golden_collar'] > 0: $equip_choice += '<<$item_name["golden_collar"]>>
'
	if slave_inventory['plain_pendant'] > 0 or inventory['plain_pendant'] > 0: $equip_choice += '<<$item_name["plain_pendant"]>>
'
	if slave_inventory['incrusted_necklace'] > 0 or inventory['incrusted_necklace'] > 0: $equip_choice += '<<$item_name["incrusted_necklace"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_hands_list = {
	slot = 28
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["gloves"]
	if $item_name[$slave["gloves"]] ! '' and $item_name[$slave["gloves"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['leather_straps'] > 0 or inventory['leather_straps'] > 0: $equip_choice += '<<$item_name["leather_straps"]>>
'
	if slave_inventory['rubber_gloves'] > 0 or inventory['rubber_gloves'] > 0: $equip_choice += '<<$item_name["rubber_gloves"]>>
'
	if slave_inventory['laced_gloves'] > 0 or inventory['laced_gloves'] > 0: $equip_choice += '<<$item_name["laced_gloves"]>>
'
	if slave_inventory['plastic_bracers'] > 0 or inventory['plastic_bracers'] > 0: $equip_choice += '<<$item_name["plastic_bracers"]>>
'
	if slave_inventory['fluffy_gloves'] > 0 or inventory['fluffy_gloves'] > 0: $equip_choice += '<<$item_name["fluffy_gloves"]>>
'
	if slave_inventory['leather_gloves'] > 0 or inventory['leather_gloves'] > 0: $equip_choice += '<<$item_name["leather_gloves"]>>
'
	if slave_inventory['ponygirl_harness'] > 0 or inventory['ponygirl_harness'] > 0: $equip_choice += '<<$item_name["ponygirl_harness"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_nipples_list = {
	slot = 29
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["nipplerings"]
	if $item_name[$slave["nipplerings"]] ! '' and $item_name[$slave["nipplerings"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['nipple_chain'] > 1 or inventory['nipple_chain'] > 1: $equip_choice += '<<$item_name["nipple_chain"]>>
'
	if slave_inventory['plain_earrings'] > 1 or inventory['plain_earrings'] > 1: $equip_choice += '<<$item_name["plain_earrings"]>>s
'
	if slave_inventory['barbells'] > 1 or inventory['barbells'] > 1: $equip_choice += '<<$item_name["barbells"]>>s
'
	if slave_inventory['heavy_gauge_rings'] > 1 or inventory['heavy_gauge_rings'] > 1: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>s
'
	if slave["nipple_piercing"] = 0: $equip_choice = 'Nipples are not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_clitor_list = {
	slot = 30
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["clitring"]
	if $item_name[$slave["clitring"]] ! '' and $item_name[$slave["clitring"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	if slave_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if slave_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if slave_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if slave["clit_piercing"] = 0: $equip_choice = 'Clitoris is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_feet_list = {
	slot = 31
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["boots"]
	if $item_name[$slave["boots"]] ! '' and $item_name[$slave["boots"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['leather_straps'] > 0 or inventory['leather_straps'] > 0: $equip_choice += '<<$item_name["leather_straps"]>>
'
	if slave_inventory['tabi'] > 0 or inventory['tabi'] > 0: $equip_choice += '<<$item_name["tabi"]>>
'
	if slave_inventory['fluffy_stepins'] > 0 or inventory['fluffy_stepins'] > 0: $equip_choice += '<<$item_name["fluffy_stepins"]>>
'
	if slave_inventory['pointes'] > 0 or inventory['pointes'] > 0: $equip_choice += '<<$item_name["pointes"]>>
'
	if slave_inventory['sneakers'] > 0 or inventory['sneakers'] > 0: $equip_choice += '<<$item_name["sneakers"]>>
'
	if slave_inventory['high_heels'] > 0 or inventory['high_heels'] > 0: $equip_choice += '<<$item_name["high_heels"]>>
'
	if slave_inventory['high_boots'] > 0 or inventory['high_boots'] > 0: $equip_choice += '<<$item_name["high_boots"]>>
'
	if slave_inventory['hoofed_boots'] > 0 or inventory['hoofed_boots'] > 0: $equip_choice += '<<$item_name["hoofed_boots"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_ring_list = {
	slot = 32
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["ring_left"]
	if $item_name[$slave["ring_left"]] ! '' and $item_name[$slave["ring_left"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['plain_ring'] > 0 or inventory['plain_ring'] > 0: $equip_choice += '<<$item_name["plain_ring"]>>
'
	if slave_inventory['incrusted_ring'] > 0 or inventory['incrusted_ring'] > 0: $equip_choice += '<<$item_name["incrusted_ring"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_ring_list_2 = {
	slot = 33
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["ring_right"]
	if $item_name[$slave["ring_right"]] ! '' and $item_name[$slave["ring_right"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['plain_ring'] > 0 or inventory['plain_ring'] > 0: $equip_choice += '<<$item_name["plain_ring"]>>
'
	if slave_inventory['incrusted_ring'] > 0 or inventory['incrusted_ring'] > 0: $equip_choice += '<<$item_name["incrusted_ring"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_navel_list = {
	slot = 34
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["navel"]
	if $item_name[$slave["navel"]] ! '' and $item_name[$slave["navel"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	if slave_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if slave_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if slave_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if slave["belly_piercing"] = 0: $equip_choice = 'Navel/belly is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$slave_tongue_list = {
	slot = 35
	$equip_choice = ''
	dynamic $show_item_description_and_image, $slave["tongue"]
	if $item_name[$slave["tongue"]] ! '' and $item_name[$slave["tongue"]] ! '-': $equip_choice += '- remove -
'
	if slave_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	!if slave_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if slave_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if slave_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if slave["tongue_piercing"] = 0: $equip_choice = 'Tongue is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

! Assistant Stuff
$assistant_armor_list = {
	slot = 40
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["armor"]
	if $assistant["armor"] ! '' and $assistant["armor"] ! 'без_брони': $equip_choice += '- remove armor-
'
	if комбез > 0: $equip_choice += 'Aramid Suit [<<комбез>>]
'
	if кожан > 0: $equip_choice += 'Leather Armor [<<кожан>>]
'
	if эльчуга > 0: $equip_choice += 'Elven Chainmail [<<эльчуга>>]
'
	if ячуга > 0: $equip_choice += 'Yatserin Mail [<<ячуга>>]
'
	if полудоспех > 0: $equip_choice += 'Combined Armor [<<полудоспех>>]
'
	if плейт > 0: $equip_choice += 'Gothic Plate [<<плейт>>]
'
	if кольчуга > 0: $equip_choice += 'Mithril Mail [<<кольчуга>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_wpn_list_large = {
	slot = 41
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["back_wpn"]
	if $item_name[$assistant["back_wpn"]] ! '' and $item_name[$assistant["back_wpn"]] ! '-': $equip_choice += '- unequip weapon -
'
	if фламберг > 0: $equip_choice += 'Flamberge [<<фламберг>>]
'
	if нагината > 0: $equip_choice += 'Naginata [<<нагината>>]
'
	if моргенштерн > 0: $equip_choice += 'Morningstar [<<моргенштерн>>]
'
	if грейтекс > 0: $equip_choice += 'Greataxe [<<грейтекс>>]
'
	if бита > 0: $equip_choice += 'Baseball Bat [<<бита>>]
'
	if скотобой > 0: $equip_choice += 'Cattle Prod [<<скотобой>>]
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_wpn_list = {
	slot = 42
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["left_wpn"]
	if $assistant["left_wpn"] ! '' and $assistant["left_wpn"] ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$assistant_wpn_list_2 = {
	slot = 43
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["right_wpn"]
	if $assistant["right_wpn"] ! '' and $assistant["right_wpn"] ! 'безоружный': $equip_choice += '- unequip weapon -
'
	if кнут > 0: $equip_choice += 'Whip [<<кнут>>]
'
	if шпага > 0: $equip_choice += 'Épée [<<шпага>>]
'
	if рапира > 0: $equip_choice += 'Rapier [<<рапира>>]
'
	if кончар > 0: $equip_choice += 'Koncerz [<<кончар>>]
'
	if гладиус > 0: $equip_choice += 'Gladius [<<гладиус>>]
'
	if бастард > 0: $equip_choice += 'Bastard sword [<<бастард>>]
'
	if мачете > 0: $equip_choice += 'Machete [<<мачете>>]
'
	if катана > 0: $equip_choice += 'Katana [<<катана>>]
'
	if трезубец > 0: $equip_choice += 'Trident [<<трезубец>>]
'
	if демократизатор > 0: $equip_choice += 'Baton [<<демократизатор>>]
'
	if кинжал > 0: $equip_choice += 'Dagger [<<кинжал>>]
'
	if стилет > 0: $equip_choice += 'Stiletto [<<стилет>>]
'
	if кастет > 0: $equip_choice += 'Brass Knuckles [<<кастет>>]
'
	if нагайка > 0: $equip_choice += 'Lash [<<нагайка>>]
'
	if глушилка > 0: $equip_choice += 'Stunner [<<глушилка>>]
'
	if тесак > 0: $equip_choice += 'Butcher’s Cleaver [<<тесак>>]
'
	if мулава > 0: $equip_choice += 'Mace [<<мулава>>]
'
	if $equip_choice = '':
		$equip_choice = 'Nothing suitable'
	else
		$equip_choice = '<<$equip_choice>>'
	end
	gt $curloc
}

$assistant_cloth_list = {
	slot = 44
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["cloth"]
	if $item_name[$assistant["cloth"]] ! '' and $item_name[$assistant["cloth"]] ! '-' and $item_name[$assistant["cloth"]] ! 'Naked': $equip_choice += '- strip naked -
'
	if assistant_inventory['common_apron'] > 0 or inventory['common_apron'] > 0: $equip_choice += '<<$item_name["common_apron"]>>
'
	if assistant_inventory['maid_dress'] > 0 or inventory['maid_dress'] > 0: $equip_choice += '<<$item_name["maid_dress"]>>
'
	if assistant_inventory['nurse_dress'] > 0 or inventory['nurse_dress'] > 0: $equip_choice += '<<$item_name["nurse_dress"]>>
'
	if assistant_inventory['sailor_foku'] > 0 or inventory['sailor_foku'] > 0: $equip_choice += '<<$item_name["sailor_foku"]>>
'
	if assistant_inventory['enchanter_robe'] > 0 or inventory['enchanter_robe'] > 0: $equip_choice += '<<$item_name["enchanter_robe"]>>
'
	if assistant_inventory['leotard'] > 0 or inventory['leotard'] > 0: $equip_choice += '<<$item_name["leotard"]>>
'
	if assistant_inventory['chainmail_bikini'] > 0 or inventory['chainmail_bikini'] > 0: $equip_choice += '<<$item_name["chainmail_bikini"]>>
'
	if assistant_inventory['ukata'] > 0 or inventory['ukata'] > 0: $equip_choice += '<<$item_name["ukata"]>>
'
	if assistant_inventory['sun_dress'] > 0 or inventory['sun_dress'] > 0: $equip_choice += '<<$item_name["sun_dress"]>>
'
	if assistant_inventory['laced_underwear'] > 0 or inventory['laced_underwear'] > 0: $equip_choice += '<<$item_name["laced_underwear"]>>
'
	if assistant_inventory['cocktail_dress'] > 0 or inventory['cocktail_dress'] > 0: $equip_choice += '<<$item_name["cocktail_dress"]>>
'
	if assistant_inventory['rubber_dress'] > 0 or inventory['rubber_dress'] > 0: $equip_choice += '<<$item_name["rubber_dress"]>>
'
	if assistant_inventory['bellydance'] > 0 or inventory['bellydance'] > 0: $equip_choice += '<<$item_name["bellydance"]>>
'
	if assistant_inventory['leather_corset'] > 0 or inventory['leather_corset'] > 0: $equip_choice += '<<$item_name["leather_corset"]>>
'
	if assistant_inventory['rich_dress'] > 0 or inventory['rich_dress'] > 0: $equip_choice += '<<$item_name["rich_dress"]>>
'
	if assistant_inventory['wedding_dress'] > 0 or inventory['wedding_dress'] > 0: $equip_choice += '<<$item_name["wedding_dress"]>>
'
	if assistant_inventory['anal_tail'] > 0 or inventory['anal_tail'] > 0: $equip_choice += '<<$item_name["anal_tail"]>>
'
	if assistant_inventory['cow_gear'] > 0 or inventory['cow_gear'] > 0: $equip_choice += '<<$item_name["cow_gear"]>>
'
	if assistant_inventory['petsuit'] > 0 or inventory['petsuit'] > 0: $equip_choice += '<<$item_name["petsuit"]>>
'
	if assistant_inventory['deprivation_suit'] > 0 or inventory['deprivation_suit'] > 0: $equip_choice += '<<$item_name["deprivation_suit"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_head_list = {
	slot = 45
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["headband"]
	if $item_name[$assistant["headband"]] ! '' and $item_name[$assistant["headband"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['hijab'] > 0 or inventory['hijab'] > 0: $equip_choice += '<<$item_name["hijab"]>>
'
	if assistant_inventory['crown_of_thorns'] > 0 or inventory['crown_of_thorns'] > 0: $equip_choice += '<<$item_name["crown_of_thorns"]>>
'
	if assistant_inventory['plain_tiara'] > 0 or inventory['plain_tiara'] > 0: $equip_choice += '<<$item_name["plain_tiara"]>>
'
	if assistant_inventory['incrusted_tiara'] > 0 or inventory['incrusted_tiara'] > 0: $equip_choice += '<<$item_name["incrusted_tiara"]>>
'
	if assistant_inventory['plain_headband'] > 0 or inventory['plain_headband'] > 0: $equip_choice += '<<$item_name["plain_headband"]>>
'
	if assistant_inventory['glasses'] > 0 or inventory['glasses'] > 0: $equip_choice += '<<$item_name["glasses"]>>
'
	if assistant_inventory['nekomimi'] > 0 or inventory['nekomimi'] > 0: $equip_choice += '<<$item_name["nekomimi"]>>
'
	if assistant_inventory['hairnet'] > 0 or inventory['hairnet'] > 0: $equip_choice += '<<$item_name["hairnet"]>>
'
	if assistant_inventory['exotic_wig'] > 0 or inventory['exotic_wig'] > 0: $equip_choice += '<<$item_name["exotic_wig"]>>
'
	if assistant_inventory['pony_plume'] > 0 or inventory['pony_plume'] > 0: $equip_choice += '<<$item_name["pony_plume"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_ears_list = {
	slot = 46
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["earrings"]
	if $item_name[$assistant["earrings"]] ! '' and $item_name[$assistant["earrings"]] ! '-': $equip_choice += '- remove -
'
	if assistant["ear_piercing"] = 0:
		$equip_choice += 'Ears are not pierced
'
		if assistant_inventory['incrusted_earrings'] > 1 or inventory['incrusted_earrings'] > 1: $equip_choice += 'Gemstone Clip-ons
'
	else
		if assistant_inventory['plain_earrings'] > 1 or inventory['plain_earrings'] > 1: $equip_choice += '<<$item_name["plain_earrings"]>>s
'
		if assistant_inventory['incrusted_earrings'] > 1 or inventory['incrusted_earrings'] > 1: $equip_choice += '<<$item_name["incrusted_earrings"]>>s
'
		if assistant_inventory['heavy_gauge_rings'] > 1 or inventory['heavy_gauge_rings'] > 1: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>s
'
	end
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_neck_list = {
	slot = 47
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["collar"]
	if $item_name[$assistant["collar"]] ! '' and $item_name[$assistant["collar"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['leather_collar'] > 0 or inventory['leather_collar'] > 0: $equip_choice += '<<$item_name["leather_collar"]>>
'
	if assistant_inventory['steel_collar'] > 0 or inventory['steel_collar'] > 0: $equip_choice += '<<$item_name["steel_collar"]>>
'
	if assistant_inventory['spiked_collar'] > 0 or inventory['spiked_collar'] > 0: $equip_choice += '<<$item_name["spiked_collar"]>>
'
	if assistant_inventory['dog_collar'] > 0 or inventory['dog_collar'] > 0: $equip_choice += '<<$item_name["dog_collar"]>>
'
	if assistant_inventory['golden_collar'] > 0 or inventory['golden_collar'] > 0: $equip_choice += '<<$item_name["golden_collar"]>>
'
	if assistant_inventory['plain_pendant'] > 0 or inventory['plain_pendant'] > 0: $equip_choice += '<<$item_name["plain_pendant"]>>
'
	if assistant_inventory['incrusted_necklace'] > 0 or inventory['incrusted_necklace'] > 0: $equip_choice += '<<$item_name["incrusted_necklace"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_hands_list = {
	slot = 48
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["gloves"]
	if $item_name[$assistant["gloves"]] ! '' and $item_name[$assistant["gloves"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['leather_straps'] > 0 or inventory['leather_straps'] > 0: $equip_choice += '<<$item_name["leather_straps"]>>
'
	if assistant_inventory['rubber_gloves'] > 0 or inventory['rubber_gloves'] > 0: $equip_choice += '<<$item_name["rubber_gloves"]>>
'
	if assistant_inventory['laced_gloves'] > 0 or inventory['laced_gloves'] > 0: $equip_choice += '<<$item_name["laced_gloves"]>>
'
	if assistant_inventory['plastic_bracers'] > 0 or inventory['plastic_bracers'] > 0: $equip_choice += '<<$item_name["plastic_bracers"]>>
'
	if assistant_inventory['fluffy_gloves'] > 0 or inventory['fluffy_gloves'] > 0: $equip_choice += '<<$item_name["fluffy_gloves"]>>
'
	if assistant_inventory['leather_gloves'] > 0 or inventory['leather_gloves'] > 0: $equip_choice += '<<$item_name["leather_gloves"]>>
'
	if assistant_inventory['ponygirl_harness'] > 0 or inventory['ponygirl_harness'] > 0: $equip_choice += '<<$item_name["ponygirl_harness"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_nipples_list = {
	slot = 49
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["nipplerings"]
	if $item_name[$assistant["nipplerings"]] ! '' and $item_name[$assistant["nipplerings"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['nipple_chain'] > 1 or inventory['nipple_chain'] > 1: $equip_choice += '<<$item_name["nipple_chain"]>>
'
	if assistant_inventory['plain_earrings'] > 1 or inventory['plain_earrings'] > 1: $equip_choice += '<<$item_name["plain_earrings"]>>s
'
	if assistant_inventory['barbells'] > 1 or inventory['barbells'] > 1: $equip_choice += '<<$item_name["barbells"]>>s
'
	if assistant_inventory['heavy_gauge_rings'] > 1 or inventory['heavy_gauge_rings'] > 1: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>s
'
	if assistant["nipple_piercing"] = 0: $equip_choice = 'Nipples are not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_clitor_list = {
	slot = 50
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["clitring"]
	if $item_name[$assistant["clitring"]] ! '' and $item_name[$assistant["clitring"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	if assistant_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if assistant_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if assistant_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if assistant["clit_piercing"] = 0: $equip_choice = 'Clitoris is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_feet_list = {
	slot = 51
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["boots"]
	if $item_name[$assistant["boots"]] ! '' and $item_name[$assistant["boots"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['leather_straps'] > 0 or inventory['leather_straps'] > 0: $equip_choice += '<<$item_name["leather_straps"]>>
'
	if assistant_inventory['tabi'] > 0 or inventory['tabi'] > 0: $equip_choice += '<<$item_name["tabi"]>>
'
	if assistant_inventory['fluffy_stepins'] > 0 or inventory['fluffy_stepins'] > 0: $equip_choice += '<<$item_name["fluffy_stepins"]>>
'
	if assistant_inventory['pointes'] > 0 or inventory['pointes'] > 0: $equip_choice += '<<$item_name["pointes"]>>
'
	if assistant_inventory['sneakers'] > 0 or inventory['sneakers'] > 0: $equip_choice += '<<$item_name["sneakers"]>>
'
	if assistant_inventory['high_heels'] > 0 or inventory['high_heels'] > 0: $equip_choice += '<<$item_name["high_heels"]>>
'
	if assistant_inventory['high_boots'] > 0 or inventory['high_boots'] > 0: $equip_choice += '<<$item_name["high_boots"]>>
'
	if assistant_inventory['hoofed_boots'] > 0 or inventory['hoofed_boots'] > 0: $equip_choice += '<<$item_name["hoofed_boots"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_ring_list = {
	slot = 52
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["ring_left"]
	if $item_name[$assistant["ring_left"]] ! '' and $item_name[$assistant["ring_left"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['plain_ring'] > 0 or inventory['plain_ring'] > 0: $equip_choice += '<<$item_name["plain_ring"]>>
'
	if assistant_inventory['incrusted_ring'] > 0 or inventory['incrusted_ring'] > 0: $equip_choice += '<<$item_name["incrusted_ring"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_ring_list_2 = {
	slot = 53
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["ring_right"]
	if $item_name[$assistant["ring_right"]] ! '' and $item_name[$assistant["ring_right"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['plain_ring'] > 0 or inventory['plain_ring'] > 0: $equip_choice += '<<$item_name["plain_ring"]>>
'
	if assistant_inventory['incrusted_ring'] > 0 or inventory['incrusted_ring'] > 0: $equip_choice += '<<$item_name["incrusted_ring"]>>
'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_navel_list = {
	slot = 54
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["navel"]
	if $item_name[$assistant["navel"]] ! '' and $item_name[$assistant["navel"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	if assistant_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if assistant_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if assistant_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if assistant["belly_piercing"] = 0: $equip_choice = 'Navel/belly is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$assistant_tongue_list = {
	slot = 55
	$equip_choice = ''
	dynamic $show_item_description_and_image, $assistant["tongue"]
	if $item_name[$assistant["tongue"]] ! '' and $item_name[$assistant["tongue"]] ! '-': $equip_choice += '- remove -
'
	if assistant_inventory['plain_earrings'] > 0 or inventory['plain_earrings'] > 0: $equip_choice += '<<$item_name["plain_earrings"]>>
'
	!if assistant_inventory['incrusted_earrings'] > 0 or inventory['incrusted_earrings'] > 0: $equip_choice += '<<$item_name["incrusted_earrings"]>>
'
	if assistant_inventory['barbells'] > 0 or inventory['barbells'] > 0: $equip_choice += '<<$item_name["barbells"]>>
'
	if assistant_inventory['heavy_gauge_rings'] > 0 or inventory['heavy_gauge_rings'] > 0: $equip_choice += '<<$item_name["heavy_gauge_rings"]>>
'
	if assistant["tongue_piercing"] = 0: $equip_choice += 'Tongue is not pierced'
	if $equip_choice = '': $equip_choice = 'Nothing suitable'
	gt $curloc
}

$next_enemy_click = {
	текущий += 1
	!switch to a live enemy if current one is dead (search forward / wrap around)
	if враг[текущий] ! 1: for i = текущий to количество_врагов: if враг[i] = 1: текущий = i
	if враг[текущий] ! 1: for i = 1 to текущий step 1: if враг[i] = 1: текущий = i
	gt $curloc
}

$prev_enemy_click = {
	текущий -= 1
	!switch to a live enemy if current one is dead (search backward / wrap around)
	if враг[текущий] ! 1: for i = текущий to 1 step -1: if враг[i] = 1: текущий = i
	if враг[текущий] ! 1: for i = количество_врагов to текущий step -1: if враг[i] = 1: текущий = i
	gt $curloc
}

$enlarge_breast = {
	slave['breast_enhanced'] = 1
	if slave['boobs'] < iif(slave['age'] = CONST_INT['loli_age'], 3, 6): slave['boobs'] += 1
	if $slave['boobs_img'] = 'boobs_G':  $slave['boobs_img'] = 'boobs_H'
	if $slave['boobs_img'] = 'boobs_F':  $slave['boobs_img'] = 'boobs_G'
	if $slave['boobs_img'] = 'boobs_EE': $slave['boobs_img'] = 'boobs_F'
	if $slave['boobs_img'] = 'boobs_E':  $slave['boobs_img'] = 'boobs_F'
	if $slave['boobs_img'] = 'boobs_DD': $slave['boobs_img'] = 'boobs_EE'
	if $slave['boobs_img'] = 'boobs_D':  $slave['boobs_img'] = 'boobs_E'
	if $slave['boobs_img'] = 'boobs_CC': $slave['boobs_img'] = 'boobs_DD'
	if $slave['boobs_img'] = 'boobs_C':  $slave['boobs_img'] = 'boobs_D'
	if $slave['boobs_img'] = 'boobs_BB': $slave['boobs_img'] = 'boobs_CC'
	if $slave['boobs_img'] = 'boobs_B':  $slave['boobs_img'] = 'boobs_C'
	if $slave['boobs_img'] = 'boobs_A':  $slave['boobs_img'] = 'boobs_B'

	if $slave['boobs_img'] = 'boobs_FP': $slave['boobs_img'] = 'boobs_HP'
	if $slave['boobs_img'] = 'boobs_EP': $slave['boobs_img'] = 'boobs_FP'
	if $slave['boobs_img'] = 'boobs_DP': $slave['boobs_img'] = 'boobs_EP'
	if $slave['boobs_img'] = 'boobs_CP': $slave['boobs_img'] = 'boobs_DP'
	if $slave['boobs_img'] = 'boobs_BP': $slave['boobs_img'] = 'boobs_CP'
	if $slave['boobs_img'] = 'boobs_AP': $slave['boobs_img'] = 'boobs_BP'
}

$reduce_breast = {
	slave['breast_enhanced'] = 1
	if slave['boobs'] > 0: slave['boobs'] -= 1
	if $slave['boobs_img'] = 'boobs_B':  $slave['boobs_img'] = 'boobs_A'
	if $slave['boobs_img'] = 'boobs_C':  $slave['boobs_img'] = 'boobs_B'
	if $slave['boobs_img'] = 'boobs_CC': $slave['boobs_img'] = 'boobs_BB'
	if $slave['boobs_img'] = 'boobs_D':  $slave['boobs_img'] = 'boobs_C'
	if $slave['boobs_img'] = 'boobs_DD': $slave['boobs_img'] = 'boobs_CC'
	if $slave['boobs_img'] = 'boobs_E':  $slave['boobs_img'] = 'boobs_D'
	if $slave['boobs_img'] = 'boobs_EE': $slave['boobs_img'] = 'boobs_DD'
	if $slave['boobs_img'] = 'boobs_F':  $slave['boobs_img'] = 'boobs_E'
	if $slave['boobs_img'] = 'boobs_G':  $slave['boobs_img'] = 'boobs_F'
	if $slave['boobs_img'] = 'boobs_H':  $slave['boobs_img'] = 'boobs_G'

	if $slave['boobs_img'] = 'boobs_BP': $slave['boobs_img'] = 'boobs_AP'
	if $slave['boobs_img'] = 'boobs_CP': $slave['boobs_img'] = 'boobs_BP'
	if $slave['boobs_img'] = 'boobs_DP': $slave['boobs_img'] = 'boobs_CP'
	if $slave['boobs_img'] = 'boobs_EP': $slave['boobs_img'] = 'boobs_DP'
	if $slave['boobs_img'] = 'boobs_FP': $slave['boobs_img'] = 'boobs_EP'
	if $slave['boobs_img'] = 'boobs_HP': $slave['boobs_img'] = 'boobs_FP'
}

$enlarge_assistant_breast = {
	assistant['breast_enhanced'] = 1
	if assistant['boobs'] < iif(assistant['age'] = CONST_INT['loli_age'], 3, 6): assistant['boobs'] += 1
	if $assistant['boobs_img'] = 'boobs_G':  $assistant['boobs_img'] = 'boobs_H'
	if $assistant['boobs_img'] = 'boobs_F':  $assistant['boobs_img'] = 'boobs_G'
	if $assistant['boobs_img'] = 'boobs_EE': $assistant['boobs_img'] = 'boobs_F'
	if $assistant['boobs_img'] = 'boobs_E':  $assistant['boobs_img'] = 'boobs_F'
	if $assistant['boobs_img'] = 'boobs_DD': $assistant['boobs_img'] = 'boobs_EE'
	if $assistant['boobs_img'] = 'boobs_D':  $assistant['boobs_img'] = 'boobs_E'
	if $assistant['boobs_img'] = 'boobs_CC': $assistant['boobs_img'] = 'boobs_DD'
	if $assistant['boobs_img'] = 'boobs_C':  $assistant['boobs_img'] = 'boobs_D'
	if $assistant['boobs_img'] = 'boobs_BB': $assistant['boobs_img'] = 'boobs_CC'
	if $assistant['boobs_img'] = 'boobs_B':  $assistant['boobs_img'] = 'boobs_C'
	if $assistant['boobs_img'] = 'boobs_A':  $assistant['boobs_img'] = 'boobs_B'

	if $assistant['boobs_img'] = 'boobs_FP': $assistant['boobs_img'] = 'boobs_HP'
	if $assistant['boobs_img'] = 'boobs_EP': $assistant['boobs_img'] = 'boobs_FP'
	if $assistant['boobs_img'] = 'boobs_DP': $assistant['boobs_img'] = 'boobs_EP'
	if $assistant['boobs_img'] = 'boobs_CP': $assistant['boobs_img'] = 'boobs_DP'
	if $assistant['boobs_img'] = 'boobs_BP': $assistant['boobs_img'] = 'boobs_CP'
	if $assistant['boobs_img'] = 'boobs_AP': $assistant['boobs_img'] = 'boobs_BP'
}

$reduce_assistant_breast = {
	assistant['breast_enhanced'] = 1
	if assistant['boobs'] > 0: assistant['boobs'] -= 1
	if $assistant['boobs_img'] = 'boobs_B':  $assistant['boobs_img'] = 'boobs_A'
	if $assistant['boobs_img'] = 'boobs_C':  $assistant['boobs_img'] = 'boobs_B'
	if $assistant['boobs_img'] = 'boobs_CC': $assistant['boobs_img'] = 'boobs_BB'
	if $assistant['boobs_img'] = 'boobs_D':  $assistant['boobs_img'] = 'boobs_C'
	if $assistant['boobs_img'] = 'boobs_DD': $assistant['boobs_img'] = 'boobs_CC'
	if $assistant['boobs_img'] = 'boobs_E':  $assistant['boobs_img'] = 'boobs_D'
	if $assistant['boobs_img'] = 'boobs_EE': $assistant['boobs_img'] = 'boobs_DD'
	if $assistant['boobs_img'] = 'boobs_F':  $assistant['boobs_img'] = 'boobs_E'
	if $assistant['boobs_img'] = 'boobs_G':  $assistant['boobs_img'] = 'boobs_F'
	if $assistant['boobs_img'] = 'boobs_H':  $assistant['boobs_img'] = 'boobs_G'

	if $assistant['boobs_img'] = 'boobs_BP': $assistant['boobs_img'] = 'boobs_AP'
	if $assistant['boobs_img'] = 'boobs_CP': $assistant['boobs_img'] = 'boobs_BP'
	if $assistant['boobs_img'] = 'boobs_DP': $assistant['boobs_img'] = 'boobs_CP'
	if $assistant['boobs_img'] = 'boobs_EP': $assistant['boobs_img'] = 'boobs_DP'
	if $assistant['boobs_img'] = 'boobs_FP': $assistant['boobs_img'] = 'boobs_EP'
	if $assistant['boobs_img'] = 'boobs_HP': $assistant['boobs_img'] = 'boobs_FP'
}

$pierce_breast = {
	if $slave['boobs_img'] = 'boobs_H':  $slave['boobs_img'] = 'boobs_HP'
	if $slave['boobs_img'] = 'boobs_G':  $slave['boobs_img'] = 'boobs_FP'
	if $slave['boobs_img'] = 'boobs_F':  $slave['boobs_img'] = 'boobs_FP'
	if $slave['boobs_img'] = 'boobs_EE': $slave['boobs_img'] = 'boobs_EP'
	if $slave['boobs_img'] = 'boobs_E':  $slave['boobs_img'] = 'boobs_EP'
	if $slave['boobs_img'] = 'boobs_DD': $slave['boobs_img'] = 'boobs_DP'
	if $slave['boobs_img'] = 'boobs_D':  $slave['boobs_img'] = 'boobs_DP'
	if $slave['boobs_img'] = 'boobs_CC': $slave['boobs_img'] = 'boobs_CP'
	if $slave['boobs_img'] = 'boobs_C':  $slave['boobs_img'] = 'boobs_CP'
	if $slave['boobs_img'] = 'boobs_BB': $slave['boobs_img'] = 'boobs_BP'
	if $slave['boobs_img'] = 'boobs_B':  $slave['boobs_img'] = 'boobs_BP'
	if $slave['boobs_img'] = 'boobs_A':  $slave['boobs_img'] = 'boobs_AP'
}

$pierce_clitoris = {
}

$rise_faction_fame = {
	no_rise = 0
	if $npc_alignment[$npc_id] = 'taurus' and faction_fame['kamira'] > 2: no_rise = 0
	if $npc_alignment[$npc_id] = 'serpis' and faction_fame['korvus'] > 2: no_rise = 0
	if $npc_alignment[$npc_id] = 'kamira' and faction_fame['taurus'] > 2: no_rise = 0
	if $npc_alignment[$npc_id] = 'korvus' and faction_fame['serpis'] > 2: no_rise = 0
	if noble_status > 0 and faction_fame[$npc_alignment[$npc_id]] = 5: no_rise = 1
	if no_rise = 0: faction_fame[$npc_alignment[$npc_id]] += 1
}

$death = {
	! Just print the message and wait for click anything for reading verify
	!$_d_answer = input($args[0] + ' Restart the game.')
	!killvar '$_d_answer'
	day = 0 &! redirect ESC key to main menu
	gt 'exit', $args[0]
}

!assistant rule reset (replaced $assistant_purge_rules with a single function for clear all or enable all) - ImperatorAugustus
$reset_assistant_rules = {
	!all assistant rules have been moved from independent variables to properties of the assistant array variable
	!likewise, slave rules have been moved from independent variables to properties of the slave array variable
	!properties below use same names as equivalent rules for slave so rules transfer automatically when swapping
	assistant['account_rule'] = args[0]
	assistant['cleans_rule'] = args[0]
	assistant['cooks_rule'] = args[0]
	assistant['washes_master_rule'] = args[0]
	assistant['tentacle_rule'] = iif(pet_tentacle > 0, args[0], 0)
	!properties below are assistant-exclusive (e.g. slave['account_rule'] is used, slave['buy_milk'] is not)
	!assistant_alchemist_rule was missing from previous implementation ($assistant_purge_rules)
	assistant['alchemist_rule'] = args[0]
	assistant['supervise_rule'] = args[0]
	assistant['washes_slave_rule'] = args[0]
	assistant['buy_vegetables'] = args[0]
	assistant['buy_flour'] = args[0]
	assistant['buy_spice'] = args[0]
	assistant['buy_cheese'] = args[0]
	assistant['buy_alcohol'] = args[0]
	assistant['buy_eggs'] = args[0]
	assistant['buy_milk'] = args[0]
	assistant['buy_cream'] = args[0]
	assistant['buy_mince'] = args[0]
	assistant['buy_meat'] = args[0]
	!intentionally not included: assistant_quiet_rule (quiet mode is a global policy, not assistant-specific)
}

!PRESETS
$name_preset = {
	$a = input ('Type the name of the preset. Leave blank to leave the name unchanged.
 If possible, do not make it longer than fourteen characters.')
	if $a !'': $preset_name[i] = $a
}

$save_preset = {
	preset_silence_rule[i] = 0
	preset_humility_rule[i] = 0
	preset_masturbation_rule[i] = 0
	preset_orgasm_prohibited[i] = 0
	preset_shit_prohibited[i] = 0
	preset_pet_rule[i] = 0
	preset_blowjob_rule[i] = 0
	preset_urinal_rule[i] = 0
	preset_toilet_rule[i] = 0

	preset_slave_cleans_rule[i] = 0
	preset_slave_cooks_rule[i] = 0
	preset_slave_washes_master_rule[i] = 0
	preset_slave_tentacle_rule[i] = 0

	preset_v_balls_rule[i] = 0

	preset_force_rules[i] = 0

	preset_slave_sleep_condition[i] = 0
	preset_diet_food_type[i] = 0
	preset_diet_leftovers[i] = 0
	preset_diet_type[i] = 0
	preset_diet_supplements[i] = 0

	if slave['silence_rule'] = 1: preset_silence_rule[i] = 1
	if slave['humility_rule'] = 1: preset_humility_rule[i] = 1
	if slave['masturbation_rule'] = 1: preset_masturbation_rule[i] = 1
	if slave['no_orgasm_rule'] = 1: preset_orgasm_prohibited[i] = 1
	if slave['no_shit_rule'] = 1: preset_shit_prohibited[i] = 1
	if slave['pet_rule'] = 1: preset_pet_rule[i] = 1
	if slave['blowjob_rule'] = 1: preset_blowjob_rule[i] = 1
	if slave['urinal_rule'] = 1: preset_urinal_rule[i] = 1
	if slave['toilet_rule'] = 1: preset_toilet_rule[i] = 1

	if slave['cleans_rule'] = 1: preset_slave_cleans_rule[i] = 1
	if slave['cooks_rule'] = 1: preset_slave_cooks_rule[i] = 1
	if slave['washes_master_rule'] = 1: preset_slave_washes_master_rule[i] = 1
	if slave['tentacle_rule'] = 1: preset_slave_tentacle_rule[i] = 1

	if slave['v_balls_rule'] = 1: preset_v_balls_rule[i] = 1

	if slave['force_rules'] = 1: preset_force_rules[i] = 1

	preset_slave_sleep_condition[i] = slave['sleep_condition']
	preset_diet_food_type[i] = slave['diet_food_type']
	if slave['diet_leftovers'] = 1: preset_diet_leftovers[i] = 1
	preset_diet_type[i] = slave['diet_portion']
	if slave['diet_supplements'] = 1: preset_diet_supplements[i] = 1
}

$use_preset = {
	slave['silence_rule'] = preset_silence_rule[i]
	slave['humility_rule'] = preset_humility_rule[i]
	slave['masturbation_rule'] = preset_masturbation_rule[i]
	slave['no_orgasm_rule'] = preset_orgasm_prohibited[i]
	slave['no_shit_rule'] = preset_shit_prohibited[i]
	slave['pet_rule'] = preset_pet_rule[i]
	slave['blowjob_rule'] = preset_blowjob_rule[i]
	slave['urinal_rule'] = preset_urinal_rule[i]
	slave['toilet_rule'] = preset_toilet_rule[i]

	slave['cleans_rule'] = preset_slave_cleans_rule[i]
	slave['cooks_rule'] = preset_slave_cooks_rule[i]
	slave['washes_master_rule'] = preset_slave_washes_master_rule[i]
	if pet_tentacle > 0: slave['tentacle_rule'] = preset_slave_tentacle_rule[i]

	if inventory['vaginal_balls'] > 0 and slave['virginity'] > 1: slave['v_balls_rule'] = preset_v_balls_rule[i]

	slave['force_rules'] = preset_force_rules[i]

	if boudoir = 0 and preset_slave_sleep_condition[i] = 2:
		slave['sleep_condition'] = 1
	else
		slave['sleep_condition'] = preset_slave_sleep_condition[i]
	end
	slave['diet_food_type'] = preset_diet_food_type[i]
	slave['diet_leftovers'] = preset_diet_leftovers[i]
	slave['diet_portion'] = preset_diet_type[i]
	slave['diet_supplements'] = preset_diet_supplements[i]
}

$purge_preset = {
	slave['silence_rule'] = 0
	slave['humility_rule'] = 0
	slave['masturbation_rule'] = 0
	slave['no_orgasm_rule'] = 0
	slave['no_shit_rule'] = 0
	slave['pet_rule'] = 0
	slave['blowjob_rule'] = 0
	slave['urinal_rule'] = 0
	slave['toilet_rule'] = 0

	slave['cleans_rule'] = 0
	slave['cooks_rule'] = 0
	slave['washes_master_rule'] = 0
	slave['tentacle_rule'] = 0

	slave['v_balls_rule'] = 0

	slave['force_rules'] = 0

	slave['sleep_condition'] = 0
	slave['diet_food_type'] = 0
	slave['diet_leftovers'] = 0
	slave['diet_portion'] = 1
	slave['diet_supplements'] = 0
}

!for master create screen
!TODO: replace this whopper for something more compact
!needs cycle or majjick

!for controlling starting reputation
$rise_rep = {
	if $estate = 'korvus_house':
 		if hero_points >= 80:
  			hero_points -= 80
  			if faction_fame['neutral'] = 1:
   				hero_points += 80
  			end
  			$estate = 'white_house'
			faction_fame['neutral'] = 1
			$starting_area = 'White Town'
			faction_purchase_kamira = 0
			faction_purchase_serpis = 0
			faction_purchase_taurus = 0
			faction_purchase_korvus = 0
			faction_purchase_neutral = 1
			dynamic $faction_adjustment
  		else
  			msg "Not enough character points. You need 80 points to raise this stat."
 		end
	end
	if $estate = 'taurus_house':
 		if hero_points >= 40:
  			hero_points -= 40
  			if faction_fame['korvus'] = 1:
   				hero_points += 40
  			end
			$estate = 'korvus_house'
			faction_fame['korvus'] = 1
			$starting_area = 'Necropolis'
			faction_purchase_kamira = 0
			faction_purchase_serpis = 0
			faction_purchase_taurus = 0
			faction_purchase_korvus = 1
			faction_purchase_neutral = 0
			dynamic $faction_adjustment
  		else
  			msg "Not enough character points. You need 40 points to raise this stat."
 		end
	end
	if $estate = 'serpis_house':
		if hero_points >= 20:
			hero_points -= 20
			if faction_fame['taurus'] = 1:
   				hero_points += 20
  			end
			$estate = 'taurus_house'
			faction_fame['taurus'] = 1
			$starting_area = 'Quarter of the Bull'
			faction_purchase_kamira = 0
			faction_purchase_serpis = 0
			faction_purchase_taurus = 1
			faction_purchase_korvus = 0
			faction_purchase_neutral = 0
			dynamic $faction_adjustment
  		else
  			msg "Not enough character points. You need 20 points to raise this stat."
 		end
	end
	if $estate = 'kamira_house':
 		if hero_points >= 10:
  			hero_points -= 10
		  	if faction_fame['serpis'] = 1:
		   		hero_points += 10
	  		end
			$estate = 'serpis_house'
			faction_fame['serpis'] = 1
			$starting_area = 'Serpentine Quarter'
			faction_purchase_kamira = 0
			faction_purchase_serpis = 1
			faction_purchase_taurus = 0
			faction_purchase_korvus = 0
			faction_purchase_neutral = 0
			dynamic $faction_adjustment
  		else
  			msg "Not enough character points. You need 10 points to raise this stat."
 		end
	end
	if $estate = 'slum_house':
	 	if hero_points >= 5:
	  		hero_points -= 5
	  		if faction_fame['kamira'] = 1:
	   			hero_points += 5
	  		end
			$estate = 'kamira_house'
			faction_fame['kamira'] = 1
			faction_purchase_kamira = 1
			faction_purchase_serpis = 0
			faction_purchase_taurus = 0
			faction_purchase_korvus = 0
			faction_purchase_neutral = 0
			dynamic $faction_adjustment
	  		$starting_area = 'Quarter of the Outcasts'
	  	else
	  		msg "Not enough character points. You need 5 points to raise this stat."
	 	end
	end
}

$lower_rep = {
	if $estate = 'kamira_house':
		hero_points += 5
		$estate = 'slum_house'
		faction_fame['kamira'] = 0
		$starting_area = 'The Slums'
		dynamic $faction_adjustment
	end
	if $estate = 'serpis_house':
		if faction_fame['kamira'] = 1: hero_points += 10
		$estate = 'kamira_house'
		faction_fame['serpis'] = 0
		faction_fame['kamira'] = 1
		$starting_area = 'Quarter of the Outcasts'
		faction_purchase_kamira = 1
		faction_purchase_serpis = 0
		faction_purchase_taurus = 0
		faction_purchase_korvus = 0
		faction_purchase_neutral = 0
		dynamic $faction_adjustment
	end
	if $estate = 'taurus_house':
		if faction_fame['serpis'] = 1: hero_points += 20
		$estate = 'serpis_house'
		faction_fame['taurus'] = 0
		faction_fame['serpis'] = 1
		$starting_area = 'Serpentine Quarter'
		faction_purchase_kamira = 0
		faction_purchase_serpis = 1
		faction_purchase_taurus = 0
		faction_purchase_korvus = 0
		faction_purchase_neutral = 0
		dynamic $faction_adjustment
	end
	if $estate = 'korvus_house':
		if faction_fame['taurus'] = 1: hero_points += 40
		$estate = 'taurus_house'
		faction_fame['korvus'] = 0
		faction_fame['taurus'] = 1
		$starting_area = 'Quarter of the Bull'
		faction_purchase_kamira = 0
		faction_purchase_serpis = 0
		faction_purchase_taurus = 1
		faction_purchase_korvus = 0
		faction_purchase_neutral = 0
		dynamic $faction_adjustment
	end
	if $estate = 'white_house':
		if faction_fame['korvus'] = 1: hero_points += 80
		$estate = 'korvus_house'
		faction_fame['neutral'] = 0
		faction_fame['korvus'] = 1
		$starting_area = 'Necropolis'
		faction_purchase_kamira = 0
		faction_purchase_serpis = 0
		faction_purchase_taurus = 0
		faction_purchase_korvus = 1
		faction_purchase_neutral = 0
		dynamic $faction_adjustment
	end
}

$faction_adjustment = {
	if faction_fame['neutral'] = 1:
		if faction_fame['korvus'] = 0:
			hero_points -= 40
			faction_fame['korvus'] = 1
		end
		if faction_fame['taurus'] = 0:
			hero_points -= 20
			faction_fame['taurus'] = 1
		end
		if faction_fame['serpis'] = 0:
			hero_points -= 10
			faction_fame['serpis'] = 1
		end
		if faction_fame['kamira'] = 0:
			hero_points -= 5
			faction_fame['kamira'] = 1
		end
	end
	if faction_fame['korvus'] = 1:
		if faction_fame['taurus'] = 0:
			hero_points -= 20
			faction_fame['taurus'] = 1
		end
		if faction_fame['serpis'] = 0:
			hero_points -= 10
			faction_fame['serpis'] = 1
		end
		if faction_fame['kamira'] = 0:
			hero_points -= 5
			faction_fame['kamira'] = 1
		end
	end
	if faction_fame['taurus'] = 1:
		if faction_fame['serpis'] = 0:
			hero_points -= 10
			faction_fame['serpis'] = 1
		end
		if faction_fame['kamira'] = 0:
			hero_points -= 5
			faction_fame['kamira'] = 1
		end
	end
	if faction_fame['serpis'] = 1:
		if faction_fame['kamira'] = 0:
			hero_points -= 5
			faction_fame['kamira'] = 1
		end
	end
}

$rise_str = {
	if master_str = 4:
		if hero_points >= 80:
			master_str = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_str = 3:
		if hero_points >= 40:
			master_str = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_str = 2:
		if hero_points >= 20:
			master_str = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_str = 1:
		if hero_points >= 10:
			master_str = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_str = 0:
		if hero_points >= 5:
			master_str = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_str = {
	if master_str = 1:
		master_str = 0
		hero_points += 5
	end
	if master_str = 2:
		master_str = 1
		hero_points += 10
	end
	if master_str = 3:
		master_str = 2
		hero_points += 20
	end
	if master_str = 4:
		master_str = 3
		hero_points += 40
	end
	if master_str = 5:
		master_str = 4
		hero_points += 80
	end
}

$rise_cha = {
	if master_cha = 4:
		if hero_points >= 80:
			master_cha = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_cha = 3:
		if hero_points >= 40:
			master_cha = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_cha = 2:
		if hero_points >= 20:
			master_cha = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_cha = 1:
		if hero_points >= 10:
			master_cha = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_cha = 0:
		if hero_points >= 5:
			master_cha = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_cha = {
	if master_cha = 1:
		master_cha = 0
		hero_points += 5
	end
	if master_cha = 2:
		master_cha = 1
		hero_points += 10
	end
	if master_cha = 3:
		master_cha = 2
		hero_points += 20
	end
	if master_cha = 4:
		master_cha = 3
		hero_points += 40
	end
	if master_cha = 5:
		master_cha = 4
		hero_points += 80
	end
}

$rise_libido = {
	if master_libido = 4:
		if hero_points >= 80:
			master_libido = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_libido = 3:
		if hero_points >= 40:
			master_libido = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_libido = 2:
		if hero_points >= 20:
			master_libido = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_libido = 1:
		if hero_points >= 10:
			master_libido = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_libido = 0:
		if hero_points >= 5:
			master_libido = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_libido = {
	if master_libido = 1:
		master_libido = 0
		hero_points += 5
	end
	if master_libido = 2:
		master_libido = 1
		hero_points += 10
	end
	if master_libido = 3:
		master_libido = 2
		hero_points += 20
	end
	if master_libido = 4:
		master_libido = 3
		hero_points += 40
	end
	if master_libido = 5:
		master_libido = 4
		hero_points += 80
	end
}

$rise_tutor = {
	if master_tutor = 4:
		if hero_points >= 80:
			master_tutor = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_tutor = 3:
		if hero_points >= 40:
			master_tutor = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_tutor = 2:
		if hero_points >= 20:
			master_tutor = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_tutor = 1:
		if hero_points >= 10:
			master_tutor = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_tutor = 0:
		if hero_points >= 5:
			master_tutor = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_tutor = {
	if master_tutor = 1:
		master_tutor = 0
		hero_points += 5
	end
	if master_tutor = 2:
		master_tutor = 1
		hero_points += 10
	end
	if master_tutor = 3:
		master_tutor = 2
		hero_points += 20
	end
	if master_tutor = 4:
		master_tutor = 3
		hero_points += 40
	end
	if master_tutor = 5:
		master_tutor = 4
		hero_points += 80
	end
}

$rise_butler = {
	if master_butler = 4:
		if hero_points >= 80:
			master_butler = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_butler = 3:
		if hero_points >= 40:
			master_butler = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_butler = 2:
		if hero_points >= 20:
			master_butler = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_butler = 1:
		if hero_points >= 10:
			master_butler = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_butler = 0:
		if hero_points >= 5:
			master_butler = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_butler = {
	if master_butler = 1:
		master_butler = 0
		hero_points += 5
	end
	if master_butler = 2:
		master_butler = 1
		hero_points += 10
	end
	if master_butler = 3:
		master_butler = 2
		hero_points += 20
	end
	if master_butler = 4:
		master_butler = 3
		hero_points += 40
	end
	if master_butler = 5:
		master_butler = 4
		hero_points += 80
	end
}

$rise_medic = {
	if master_medic = 4:
		if hero_points >= 80:
			master_medic = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_medic = 3:
		if hero_points >= 40:
			master_medic = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_medic = 2:
		if hero_points >= 20:
			master_medic = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_medic = 1:
		if hero_points >= 10:
			master_medic = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_medic = 0:
		if hero_points >= 5:
			master_medic = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_medic = {
	if master_medic = 1:
		master_medic = 0
		hero_points += 5
	end
	if master_medic = 2:
		master_medic = 1
		hero_points += 10
	end
	if master_medic = 3:
		master_medic = 2
		hero_points += 20
	end
	if master_medic = 4:
		master_medic = 3
		hero_points += 40
	end
	if master_medic = 5:
		master_medic = 4
		hero_points += 80
	end
}

$rise_artdirector = {
	if master_artdirector = 4:
		if hero_points >= 80:
			master_artdirector = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_artdirector = 3:
		if hero_points >= 40:
			master_artdirector = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_artdirector = 2:
		if hero_points >= 20:
			master_artdirector = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_artdirector = 1:
		if hero_points >= 10:
			master_artdirector = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_artdirector = 0:
		if hero_points >= 5:
			master_artdirector = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_artdirector = {
	if master_artdirector = 1:
		master_artdirector = 0
		hero_points += 5
	end
	if master_artdirector = 2:
		master_artdirector = 1
		hero_points += 10
	end
	if master_artdirector = 3:
		master_artdirector = 2
		hero_points += 20
	end
	if master_artdirector = 4:
		master_artdirector = 3
		hero_points += 40
	end
	if master_artdirector = 5:
		master_artdirector = 4
		hero_points += 80
	end
}

$rise_fighter = {
	if master_fighter = 4:
		if hero_points >= 80:
			master_fighter = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_fighter = 3:
		if hero_points >= 40:
			master_fighter = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_fighter = 2:
		if hero_points >= 20:
			master_fighter = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_fighter = 1:
		if hero_points >= 10:
			master_fighter = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_fighter = 0:
		if hero_points >= 5:
			master_fighter = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_fighter = {
	if master_fighter = 1:
		master_fighter = 0
		hero_points += 5
	end
	if master_fighter = 2:
		master_fighter = 1
		hero_points += 10
	end
	if master_fighter = 3:
		master_fighter = 2
		hero_points += 20
	end
	if master_fighter = 4:
		master_fighter = 3
		hero_points += 40
	end
	if master_fighter = 5:
		master_fighter = 4
		hero_points += 80
	end
}

$rise_mage = {
	if master_mage = 4:
		if hero_points >= 80:
			master_mage = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_mage = 3:
		if hero_points >= 40:
			master_mage = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_mage = 2:
		if hero_points >= 20:
			master_mage = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_mage = 1:
		if hero_points >= 10:
			master_mage = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_mage = 0:
		if hero_points >= 5:
			master_mage = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_mage = {
	if master_mage = 1:
		master_mage = 0
		hero_points += 5
	end
	if master_mage = 2:
		master_mage = 1
		hero_points += 10
	end
	if master_mage = 3:
		master_mage = 2
		hero_points += 20
	end
	if master_mage = 4:
		master_mage = 3
		hero_points += 40
	end
	if master_mage = 5:
		master_mage = 4
		hero_points += 80
	end
}

$rise_domination = {
	if master_domination = 4:
		if hero_points >= 80:
			master_domination = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_domination = 3:
		if hero_points >= 40:
			master_domination = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_domination = 2:
		if hero_points >= 20:
			master_domination = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_domination = 1:
		if hero_points >= 10:
			master_domination = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_domination = 0:
		if hero_points >= 5:
			master_domination = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_domination = {
	if master_domination = 1:
		master_domination = 0
		hero_points += 5
	end
	if master_domination = 2:
		master_domination = 1
		hero_points += 10
	end
	if master_domination = 3:
		master_domination = 2
		hero_points += 20
	end
	if master_domination = 4:
		master_domination = 3
		hero_points += 40
	end
	if master_domination = 5:
		master_domination = 4
		hero_points += 80
	end
}

$rise_flagelation = {
	if master_flagelation = 4:
		if hero_points >= 80:
			master_flagelation = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_flagelation = 3:
		if hero_points >= 40:
			master_flagelation = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_flagelation = 2:
		if hero_points >= 20:
			master_flagelation = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_flagelation = 1:
		if hero_points >= 10:
			master_flagelation = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_flagelation = 0:
		if hero_points >= 5:
			master_flagelation = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_flagelation = {
	if master_flagelation = 1:
		master_flagelation = 0
		hero_points += 5
	end
	if master_flagelation = 2:
		master_flagelation = 1
		hero_points += 10
	end
	if master_flagelation = 3:
		master_flagelation = 2
		hero_points += 20
	end
	if master_flagelation = 4:
		master_flagelation = 3
		hero_points += 40
	end
	if master_flagelation = 5:
		master_flagelation = 4
		hero_points += 80
	end
}

$rise_torture = {
	if master_torture = 4:
		if hero_points >= 80:
			master_torture = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_torture = 3:
		if hero_points >= 40:
			master_torture = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_torture = 2:
		if hero_points >= 20:
			master_torture = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_torture = 1:
		if hero_points >= 10:
			master_torture = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_torture = 0:
		if hero_points >= 5:
			master_torture = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_torture = {
	if master_torture = 1:
		master_torture = 0
		hero_points += 5
	end
	if master_torture = 2:
		master_torture = 1
		hero_points += 10
	end
	if master_torture = 3:
		master_torture = 2
		hero_points += 20
	end
	if master_torture = 4:
		master_torture = 3
		hero_points += 40
	end
	if master_torture = 5:
		master_torture = 4
		hero_points += 80
	end
}

$rise_bondage = {
	if master_bondage = 4:
		if hero_points >= 80:
			master_bondage = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_bondage = 3:
		if hero_points >= 40:
			master_bondage = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_bondage = 2:
		if hero_points >= 20:
			master_bondage = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_bondage = 1:
		if hero_points >= 10:
			master_bondage = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_bondage = 0:
		if hero_points >= 5:
			master_bondage = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_bondage = {
	if master_bondage = 1:
		master_bondage = 0
		hero_points += 5
	end
	if master_bondage = 2:
		master_bondage = 1
		hero_points += 10
	end
	if master_bondage = 3:
		master_bondage = 2
		hero_points += 20
	end
	if master_bondage = 4:
		master_bondage = 3
		hero_points += 40
	end
	if master_bondage = 5:
		master_bondage = 4
		hero_points += 80
	end
}

$rise_petting = {
	if master_petting = 4:
		if hero_points >= 80:
			master_petting = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_petting = 3:
		if hero_points >= 40:
			master_petting = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_petting = 2:
		if hero_points >= 20:
			master_petting = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_petting = 1:
		if hero_points >= 10:
			master_petting = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_petting = 0:
		if hero_points >= 5:
			master_petting = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_petting = {
	if master_petting = 1:
		master_petting = 0
		hero_points += 5
	end
	if master_petting = 2:
		master_petting = 1
		hero_points += 10
	end
	if master_petting = 3:
		master_petting = 2
		hero_points += 20
	end
	if master_petting = 4:
		master_petting = 3
		hero_points += 40
	end
	if master_petting = 5:
		master_petting = 4
		hero_points += 80
	end
}

$rise_penetration = {
	if master_penetration = 4:
		if hero_points >= 80:
			master_penetration = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_penetration = 3:
		if hero_points >= 40:
			master_penetration = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_penetration = 2:
		if hero_points >= 20:
			master_penetration = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_penetration = 1:
		if hero_points >= 10:
			master_penetration = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_penetration = 0:
		if hero_points >= 5:
			master_penetration = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_penetration = {
	if master_penetration = 1:
		master_penetration = 0
		hero_points += 5
	end
	if master_penetration = 2:
		master_penetration = 1
		hero_points += 10
	end
	if master_penetration = 3:
		master_penetration = 2
		hero_points += 20
	end
	if master_penetration = 4:
		master_penetration = 3
		hero_points += 40
	end
	if master_penetration = 5:
		master_penetration = 4
		hero_points += 80
	end
}

$rise_oral = {
	if master_oral = 4:
		if hero_points >= 80:
			master_oral = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_oral = 3:
		if hero_points >= 40:
			master_oral = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_oral = 2:
		if hero_points >= 20:
			master_oral = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_oral = 1:
		if hero_points >= 10:
			master_oral = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_oral = 0:
		if hero_points >= 5:
			master_oral = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_oral = {
	if master_oral = 1:
		master_oral = 0
		hero_points += 5
	end
	if master_oral = 2:
		master_oral = 1
		hero_points += 10
	end
	if master_oral = 3:
		master_oral = 2
		hero_points += 20
	end
	if master_oral = 4:
		master_oral = 3
		hero_points += 40
	end
	if master_oral = 5:
		master_oral = 4
		hero_points += 80
	end
}

$rise_fetish = {
	if master_fetish = 4:
		if hero_points >= 80:
			master_fetish = 5
			hero_points -= 80
		else
			msg "Not enough character points. You need 80 points to raise this stat to the fifth level."
		end
	end
	if master_fetish = 3:
		if hero_points >= 40:
			master_fetish = 4
			hero_points -= 40
		else
			msg "Not enough character points. You need 40 points to raise this stat to the fourth level."
		end
	end
	if master_fetish = 2:
		if hero_points >= 20:
			master_fetish = 3
			hero_points -= 20
		else
			msg "Not enough character points. You need 20 points to raise this stat to the third level."
		end
	end
	if master_fetish = 1:
		if hero_points >= 10:
			master_fetish = 2
			hero_points -= 10
		else
			msg "Not enough character points. You need 10 points to raise this stat to the second level."
		end
	end
	if master_fetish = 0:
		if hero_points >= 5:
			master_fetish = 1
			hero_points -= 5
		else
			msg "Not enough character points. You need 5 points to raise this stat to the first level."
		end
	end
}

$lower_fetish = {
	if master_fetish = 1:
		master_fetish = 0
		hero_points += 5
	end
	if master_fetish = 2:
		master_fetish = 1
		hero_points += 10
	end
	if master_fetish = 3:
		master_fetish = 2
		hero_points += 20
	end
	if master_fetish = 4:
		master_fetish = 3
		hero_points += 40
	end
	if master_fetish = 5:
		master_fetish = 4
		hero_points += 80
	end
}

$guro_off = {
	no_guro = 1
	$bg['slaughter'] = 'empty'
	$bg['tavern_kitchen'] = 'empty'
	$bg['slaughter2'] = 'empty'
	$npc_image['bullhorn'] = ''
}

$guro_on = {
	no_guro = 0
	$bg['slaughter'] = 'slaughter'
	$bg['tavern_kitchen'] = 'tavern_kitchen'
	$npc_image['bullhorn'] = 'bullhorn'
}

!Cryo Sleep - new buttons on main menu feature - crushboss (converted to dynamic - ImperatorAugustus)
$show_main_screen_cryo_cell_button = {
	cryo_cell_button_number = val(replace($args[0], 'iced_', ''))
	if dyneval("result = iced_<<cryo_cell_button_number>>_state") = CONST_INT['no_slave']:
		*p '<div id = "stasis_cell_<<cryo_cell_button_number>>"><a class="tooltip-left" tooltip-data="Cryo Storage - Cell <<cryo_cell_button_number>>" href = "EXEC: cryo_cell_selected = <<cryo_cell_button_number>> & gs ''slave_to_iced'', <<cryo_cell_button_number>> & gt ''menu_form''"><img src = "content\pic\ui\crushboss\white_<<cryo_cell_button_number>>.png">
'
	else
		*p '<div id = "stasis_cell_<<cryo_cell_button_number>>"><a class="tooltip-left" tooltip-data="Cryo Storage - Cell <<cryo_cell_button_number>>" href = "EXEC: cryo_cell_selected = <<cryo_cell_button_number>> & gt ''menu_form''"><img src = "content\pic\ui\crushboss\arousal_<<cryo_cell_button_number>>.png">
'
	end
}

!Cryo Storage - Selected cell - crushboss (converted to dynamic - ImperatorAugustus)
$show_main_screen_selected_cryo_cell_avatar = {
	if dyneval("result = iced_<<cryo_cell_selected>>_state") ! CONST_INT['no_slave']:
		dynamic "$cryo_cell_avatar_slave_name = $iced_<<cryo_cell_selected>>_name"
		dynamic "$cryo_cell_avatar_image = $<<'iced_'+$str(cryo_cell_selected)+'[''ava_gray'']'>>"
		*p '
<a class="tooltip-left-huge" tooltip-data="<<$cryo_cell_avatar_slave_name>> in Cryo Storage - Cell <<cryo_cell_selected>>" href = "EXEC: gs ''slave_to_iced'', <<cryo_cell_selected>> & gt ''menu_form''"><img src = "<<$cryo_cell_avatar_image>>.png">
'
	end
}

$chariotweight = {
	chariot_weight = (heavy_frame + heavy_boards + heavy_chassis + heavy_wheels + heavy_rider_armor) + 5
}

$msgsmallfont = {
	!currently used only for rules explanations on slave_stat screen
	msg '
<<$args[0]>>
'
}

$msg = {
	$MSG_FORMAT = '
%TEXT%
'
	msg '<<$args[0]>>'
}

$milking_result = {
	$text[2] = '  The overall result of the milking: <<milk_bottle_plus>> bottle<<iif(milk_bottle_plus ! 1, "s", "")>> of milk.'
	if milk_bottle_plus > 0:
		dynamic $get_fridge_space
		if fridge_space >= 10:
			milk_bottle_plus += fridge['milk']
			fridge['milk'] = 0
			if milk_bottle_plus <= 10:
				fridge['milk'] = milk_bottle_plus
				milk_bottle_plus = 0
			else
				fridge['milk'] = 10
				milk_bottle_plus -= 10
			end
		end
		if milk_bottle_plus > 0:
			if milk_can = 1:
				milk_stock += milk_bottle_plus
				if milk_stock > 100:
					milk_stock = 100
					$text[2] += '

  Your milk tank can stock only one hundred bottles of milk. The surplus was discarded.'
				end
			else
				$text[3] = '  Your fridge can stock only ten bottles of milk and is currently full. You need to invest in a milk tank to keep your surplus.'
			end
		end
		milk_bottle_plus = 0
	end
}

$milk_price = {
	if milk_tip ! 1:
		milk_price += rand(-1,1)
	end

	if milk_tip = 1:
		if milk_demand = 0: milk_price -= 1
		if milk_demand = 1: milk_price += 0
		if milk_demand = 2: milk_price += 1
	end

	if milk_price < 1: milk_price = 1
	if milk_price > 4: milk_price = 4
}

!wore clothes and equipments are sold along the slave - Pianocat
$sold_clothing = {
	slave_inventory[$slave["cloth"]] -= 1
	slave_inventory[$slave["headband"]] -= 1
	slave_inventory[$slave["earrings"]] -= 2
	slave_inventory[$slave["collar"]] -= 1
	slave_inventory[$slave["gloves"]] -= 1
	slave_inventory[$slave["boots"]] -= 1
	slave_inventory[$slave["nipplerings"]] -= 1
	slave_inventory[$slave["clitring"]] -= 1
	slave_inventory[$slave["navel"]] -= 1
	slave_inventory[$slave["tongue"]] -= 1
	slave_inventory[$slave["ring_right"]] -= 1
	slave_inventory[$slave["ring_left"]] -= 1
	slave_inventory[$slave["armor"]] -= 1
	slave_inventory[$slave["back_wpn"]] -= 1
	slave_inventory[$slave["left_wpn"]] -= 1
	slave_inventory[$slave["right_wpn"]] -= 1
}

$inseminate = {
	!simplifying assumption: even if ejaculation_intensity = 0 (master did not cum inside), enough sperm was introduced via precum or otherwise
	!sperm remain viable for 3-5 days after insemination (overwrite pre-existing value, because hunter-killer sperm and statistical variability)
	dynamic "<<$args[0]>>['inseminated'] = rand(3,5) & <<$args[0]>>['cum_load'] += ejaculation_intensity"
}

$vaginally_penetrated = {
	! actually called from interaction_result, but implemented in interaction in $special_part sections (expects to be called with a slave instance as parameter)
	! expects to be called with dynamic $replace($vaginally_penetrated, 'dyn'+'slave', 'a slave instance variable')
	if dynslave_state > CONST_INT['no_slave']:

		if dynslave['virginity'] < 2:
			if dynslave['virginity'] ! 1:
				! check for restored hymen to close potential exploit, and make simplifying assumption that master is around if not involved - ImperatorAugustus
				if is_perv ! 0 and dynslave['age'] = CONST_INT['loli_age']:
					master_perv_rate += 10
					if ejaculation_intensity > 0 and dynslave['age'] = CONST_INT['loli_age']: was_virgin = 1 &! flag for Uncle Tom (see $calculate_attributes)
				end
				!qwertyu12359 virgin rape effects: -1 nature, -1 temperament, -1 pride if above timid, +2 angst (added rape_fear calculation, keep in sync with $dyn_rape_effects - ImperatorAugustus)
				rape_fear = max(0, (1 - dynslave['arousal']/5) + (dynslave['pride']*2 + dynslave['ego']*2 + dynslave['intellect'] + dynslave['temper'] - dynslave['moral']*4))
				if dynslave['abuse_attitude'] = -1 or dynslave['nymphomania'] < 0: rape_fear *= 2
				if dynslave['abuse_attitude'] = 1 or dynslave['nymphomania'] > 0: rape_fear /= 2
				if dynslave['abuse_attitude'] = 2 or dynslave['moral'] = 5: rape_fear = 0 &! zero for psi-masochists or fully devoted slaves
				if rape_fear > 0 and ($interaction_type = 'rape' or $interaction_type = 'torture' or dynslave['domini_dictum'] = 1):
					dynslave['ego'] -= 1
					dynslave_rate['ego'] = dynslave['angst'] * -1
					dynslave['temper'] -= 1
					dynslave_rate['temper'] = dynslave['angst'] * -1
					if dynslave['pride'] > 2:
						dynslave['pride'] -= 1
						dynslave_rate['pride'] = 0
					end
					dynslave['angst'] += 2
				end
			end
			if dynslave['masochism'] ! 2: dynslave['neg_defloration'] = max(0, 1 + dynslave['sensitivity'] + dynslave['pride'] - dynslave['moral']*2 - dynslave['arousal'])
			! above formula is balanced so that maxed devotion and arousal exactly negate maxed sensitivity and pride - ImperatorAugustus
			if dynslave['neg_defloration'] > 0: gs '$mood_drop', 'dynslave', dynslave['neg_defloration']
			dynslave['virginity'] = 2
		end

		if dynslave['sub_vaginal'] < 1: dynslave['sub_vaginal'] = 1

		if ejaculation_intensity > 0:
			!TODO: assuming that ejaculation_intensity > 0 implies the vaginal penetration was done by the master is not necessarily true in all cases - ImperatorAugustus
			dynamic $master_ejaculate
			dynamic $inseminate, 'dynslave'
			master_penetration_rate += (skill_adv_mul * 1)
			if master_ill = 0 and dynslave['ill'] > 0 and rand(1,6) > master_str: master_ill += 1 &! venereal disease transmission to master
			if master_ill > 0 and dynslave['ill'] = 0 and rand(1,6) > dynslave['stamina']: dynslave['ill'] += 1 &! venereal disease transmission to slave
		end

	end
}

$console = {
	$command = $trim($input("*Don't use unless you know what you're doing*"))
	if mid($command,1,1) = '@':
		dynamic $mid($command,2)
	elseif instr($command, ' ') > 0:
		msg 'invalid input (contains whitespace): use @ prefix for commands'
	else
		dynamic "msg " + $command
	end
}

! 0 -> index, 1 -> text
$save_link = {
	if args[0] ! -1:
		$menu_links[args[0]] = $args[1]
	else
		killvar '$menu_links'
	end
}

--- #dynamic ---------------------------------