code:
# $cow_price
!Cow Price Calculation - Pianocat
!Also sets $cow_auction strings (relocated from #txt_2 database because these strings contain subexpressions referring to variables that are set here) - ImperatorAugustus

cowprice = 0

!Price for cows
cow_base_price = 20

if cow['fat'] = 0: cow_base_price -= 500
if cow['fat'] = 1: cow_base_price -= 100
if cow['fat'] = 3: cow_base_price += 60
if cow['fat'] = 4: cow_base_price += 100
if cow['fat'] = 5: cow_base_price += 40

if cow['ego'] = 0: cow_base_price += 100
if cow['ego'] = 1: cow_base_price += 60
if cow['ego'] = 2: cow_base_price += 20
if cow['ego'] = 3: cow_base_price -= 30
if cow['ego'] = 4: cow_base_price -= 60
if cow['ego'] = 5: cow_base_price -= 100

if cow['pride'] = 0: cow_base_price += 100
if cow['pride'] = 1: cow_base_price += 60
if cow['pride'] = 2: cow_base_price += 20
if cow['pride'] = 3: cow_base_price -= 30
if cow['pride'] = 4: cow_base_price -= 60
if cow['pride'] = 5: cow_base_price -= 300

if cow['stamina'] = 1: cow_base_price -= 150
if cow['stamina'] = 2: cow_base_price += 0
if cow['stamina'] = 3: cow_base_price += 40
if cow['stamina'] = 4: cow_base_price += 80
if cow['stamina'] = 5: cow_base_price += 150

if cow['pet'] = 1: cow_base_price += 10
if cow['pet'] = 2: cow_base_price += 20
if cow['pet'] = 3: cow_base_price += 40
if cow['pet'] = 4: cow_base_price += 80
if cow['pet'] = 5: cow_base_price += 100

if cow['dressage'] = 1: cow_base_price += 10
if cow['dressage'] = 2: cow_base_price += 20
if cow['dressage'] = 3: cow_base_price += 40
if cow['dressage'] = 4: cow_base_price += 80
if cow['dressage'] = 5: cow_base_price += 100

if cow['xenophily'] = 0: cow_base_price -= 200
if cow['xenophily'] = 1: cow_base_price -= 100
if cow['xenophily'] = 2: cow_base_price += 20
if cow['xenophily'] = 3: cow_base_price += 100
if cow['xenophily'] = 4: cow_base_price += 200
if cow['xenophily'] = 5: cow_base_price += 300

if cow['cowSK'] = 3: cow_base_price -= 400
if cow['cowSK'] = 4: cow_base_price += 100
if cow['cowSK'] = 5: cow_base_price += 800

if cow['mood'] = 0: cow_base_price += 50
if cow['mood'] = 1: cow_base_price += 100
if cow['mood'] = 2: cow_base_price += 150
if cow['mood'] = 3: cow_base_price += 200
if cow['mood'] = 4: cow_base_price += 250
if cow['mood'] = 5: cow_base_price += 300
if cow['mood'] = 6: cow_base_price -= 20
if cow['mood'] = 7: cow_base_price -= 40
if cow['mood'] = 8: cow_base_price -= 60
if cow['mood'] = 9: cow_base_price -= 100
if cow['mood'] = 10: cow_base_price -= 250

!The two max levels of instinct and custom calculations add up: eg, cow with 2 instinct will value +60 sparks/cow with 5 instinct will value +160 sparks
if cow['instinct'] = 0: cow_base_price -= 40
if cow['instinct'] > 0: cow_base_price += 60
if cow['instinct'] > 3: cow_base_price += 100
if cow['custom'] = 0: cow_base_price -= 40
if cow['custom'] > 0: cow_base_price += 60
if cow['custom'] > 3: cow_base_price += 100

if cow['angst'] = 0: cow_base_price += 80
if cow['angst'] = 1: cow_base_price -= 60
if cow['angst'] = 2: cow_base_price -= 120
if cow['angst'] = 3: cow_base_price -= 180
if cow['angst'] = 4: cow_base_price -= 250
if cow['angst'] = 5: cow_base_price -= 500

if cow['fear'] = 0: cow_base_price += 150
if cow['fear'] = 1: cow_base_price += 20
if cow['fear'] = 2: cow_base_price -= 40
if cow['fear'] = 3: cow_base_price -= 80
if cow['fear'] = 4: cow_base_price -= 120
if cow['fear'] = 5: cow_base_price -= 150

if cow['boobs'] = 0: cow_base_price -= 400
if cow['boobs'] = 1: cow_base_price -= 200
if cow['boobs'] = 2: cow_base_price -= 100
if cow['boobs'] = 3: cow_base_price += 20
if cow['boobs'] = 4: cow_base_price += 150
if cow['boobs'] = 5: cow_base_price += 300
if cow['boobs'] = 6: cow_base_price += 500

if cow['virginity'] = 3: cow_base_price += 80
if cow['sub_fisting'] > 2: cow_base_price += 40
if cow['sub_fisting'] > 4: cow_base_price += 40

if cow['age'] = CONST_INT['milf_age']: cow_base_price += 150

if cow['cowSK_affinity'] > 0: cow_base_price += 250

if $cow_psy_status = 'broken': cow_base_price = cow_base_price/2

!bonus for master capacity to lead negotiation and impress Jarik
cow_base_price += master_str*10
cow_base_price += master_cha*10
cow_base_price += master_style*10
cow_base_price += brand_reputation*10
cow_base_price += guild_reputation*10

if cow_base_price < 20: cow_base_price = 20

!Calculate cow price
cowprice = (cow_base_price*3)/2
if cowprice < 30: cowprice = 30

!Cow auction text
if cow['age'] ! CONST_INT['milf_age']: $csell_age = 'She looks a bit young, but it’s not a big deal:'
if cow['age'] = CONST_INT['milf_age']: $csell_age = 'She’s mature, it’s always a good thing:'

if cow['cowSK'] = 3: $csell_cowSK = ' the real issue is her lack of skill to behave like a cow. We will have to finish the job ourself, and we cannot be sure that she will not break before the end of her "training"... It’s really a negative point for both of us, sir-trainer.'
if cow['cowSK'] = 4: $csell_cowSK = ' one thing, though: she’s not completely trained to be a cow, huh? She seems a bit conditioned, but it’s not sufficient to significantly increase her value, sorry sir-trainer...'
if cow['cowSK'] = 5: $csell_cowSK = ' and, most importantly, she seems perfectly trained and "skilled" for her role as a cow. For us, getting perfectly conditioned girls is crucial, they’re safe bets... So we can go on, for sure we will both make a good deal. '

if cow['boobs'] = 0: $csell_boobs = 'Damn. Where is her chest? You know we’re looking for milk cow, huh?'
if cow['boobs'] = 1: $csell_boobs = 'She’s almost flat-chested... Not a good one.'
if cow['boobs'] = 2: $csell_boobs = 'Not a good start... I saw many females, during my career, with more boobs than your "cow."'
if cow['boobs'] = 3: $csell_boobs = 'She has nice breasts. Nothing spectacular but, well, it should do the job.'
if cow['boobs'] = 4: $csell_boobs = 'It’s a good start, her breasts are perfectly fitted to match our average production.'
if cow['boobs'] = 5: $csell_boobs = 'Beautiful boobs! We rarely see this "caliber": you score a point, sir-trainer.'
if cow['boobs'] = 6: $csell_boobs = 'Absolutely spectacular. If these breasts keep their promises, we could here have the cow of the year!'

if cow['fat'] = 0: $csell_fat = ' Hmm... She looks like a skeleton. She’s far much too skinny!'
if cow['fat'] = 1: $csell_fat = ' Well, she’s a bit skinny. Not a good thing, it will impacts her production.'
if cow['fat'] = 2: $csell_fat = ' Her weight seems quiet normal, nothing special.'
if cow['fat'] = 3: $csell_fat = ' Hmm,she seems a bit plump. That’s a good thing.'
if cow['fat'] = 4: $csell_fat = ' Anyway she has the perfect weight for a cow, just fat enough!'
if cow['fat'] = 5: $csell_fat = ' Impressive... well, she’s not skinny, for sure, it’s better like this, but we will have to make some room in the shed...'

if cow['stamina'] = 1: $csell_stamina = ' she can barely put a foot in front of the other... I know it’s not essential for a cow, but she’s too weak.'
if cow['stamina'] = 2: $csell_stamina = ' she’s a bit weak, but nothing unusual for a milk cow. We do not require them to run a marathon, isn’t that right?'
if cow['stamina'] = 3: $csell_stamina = ' she’s healthy, it’s always a good thing, to prevent infections and diseases.'
if cow['stamina'] = 4: $csell_stamina = ' she looks quite fit, it’s not that much important, but I appreciate!'
if cow['stamina'] = 5: $csell_stamina = ' she doesn’t sweat a drop! It’s extremely rare to see a cow with such a shape. And almost a shame to shut her up in a barn: anyway it’s a nice bonus.'

if cow['ego'] = 0: $csell_ego = ' she seems totally spineless, that’s perfect. We want our cow to be easily manipulable.'
if cow['ego'] = 1: $csell_ego = ' she looks pretty inoffensive, it’s a good thing.'
if cow['ego'] = 2: $csell_ego = ' it could be worse, but she looks a bit lost, her mind isn’t totally submissive.'
if cow['ego'] = 3: $csell_ego = ' she looks quite independent, it’s not a good thing for a cow, though it shouldn’t be a big issue in this case.'
if cow['ego'] = 4: $csell_ego = ' she’s very independent, it’s a rare thing in a barn. I hope she will not cause troubles...'
if cow['ego'] = 5: $csell_ego = ' it’s not good, I never saw a cow with such a strong will! How did you manage to train this girl without breaking her at all? Cows don’t need to be willful: I hope it will not lead her to misbehave...'

if cow['pride'] = 0: $csell_pride = ' a good point, she’s totally unashamed. It’s better, knowing she will spend her life naked, you see...?'
if cow['pride'] = 1: $csell_pride = ' well, she does look timid... It will ease things concerning inseminations and milking.'
if cow['pride'] = 2: $csell_pride = ' she could be more open, less ashamed, you see? Don’t worry, it will not impact her price, she will quickly be used to her daily "treatment."'
if cow['pride'] = 3: $csell_pride = ' she’s proud, sir-trainer... Not a good point, sometimes this kind of girl is a bit reluctant. But we saw worst cases, so...'
if cow['pride'] = 4: $csell_pride = ' she’s clearly too proud! Don’t you tried to open her a bit more? Life here will be difficult for her... and she risks to make ours difficult, too...'
if cow['pride'] = 5: $csell_pride = ' she’s an arrogant cow! Is this a joke? I thought it was impossible... She will clearly cause troubles, you know...'

if cow['instinct'] = 0: $csell_instinct = 'She looks like a slave who’s not really accepting her condition, it’s clearly not instinctive for her: she’s perhaps rather obedient, but she has to be tamed...'
if cow['instinct'] > 0: $csell_instinct = 'She could be more accustomed to obey and quickly react to her master’s wishes. But you already did good work taming her: we will easily finish it.'
if cow['instinct'] > 3: $csell_instinct = 'She looks tamed enough, that’s a good thing. With some more time it will become totally natural for her to be a cow.'

if cow['custom'] = 0: $csell_custom = 'She’s not accustomed to her situation, so she might end up causing trouble...'
if cow['custom'] > 0: $csell_custom = 'She is somewhat accustomed to obey, it’s a good thing. It could be better, though.'
if cow['custom'] > 3: $csell_custom = 'Be that as it may, she seems pretty accustomed to her life as a cow: it’s perfect, our cattle don’t have to be focused on anything other than milk production!'

if cow['pet'] < 3 and cow['dressage'] < 3:
 	$csell_pet = 'You say she’s not really familiar with role playing? Not a big deal, it’s only a bonus: cows that are deeply conditioned to assume animals roles are often a bit easier to control.'
elseif cow['pet'] < 3 and cow['dressage'] > 2:
 	$csell_pet = 'You have trained her a bit, huh? Some training to behave like an animal never hurts... he who can do more can do less, isn’t that right?'
elseif cow['pet'] > 2 and cow['dressage'] < 3:
 	$csell_pet = 'You have trained her a bit, huh? Some training to behave like an animal never hurts... he who can do more can do less, isn’t that right?'
elseif cow['pet'] > 2 and cow['dressage'] > 2:
 	$csell_pet = 'She’s familiar with behaving like an animal? Perfect. It’s far from essential, but it is worth some more sparks, for sure: it’s better for conditioning, you see?'
end

if cow['xenophily'] < 2: $csell_xeno = 'Even so, it’s problematic that she’s not used to xenophilia: you know, minotaurs often take care of inseminations, so it’s better if girls are used to non-human sex.'
if cow['xenophily'] = 2: $csell_xeno = 'Anyway, she seems at ease with xenophilia: she will have to deal with minotaurs, several times each month... Cows which aren’t accustomed to us can be afraid the first times: it’s bad for their productivity.'
if cow['xenophily'] > 3: $csell_xeno = 'And she seems at least as much familiar with xenophilia as with human sex: this is a very good point, we will be able to start the insemination process quickly, and by any "means", if I may say so...'

if cow['virginity'] = 3: $csell_virginity = 'Good, her vagina is relaxed, it will help for inseminations.'
if cow['virginity'] ! 3: $csell_virginity = 'Her vagina is a bit too firm: that’s not really important, though, but we will have to take care not to hurt her.'
if cow['sub_fisting'] < 3: $csell_fisting = 'However you should have worked on fisting her: it’s a good way to "relax" her, you know.'
if cow['sub_fisting'] > 2: $csell_fisting = 'She’s familiar with fisting? Good. A lot of farmers totally underestimate the value of this practice to ease inseminations.'
if cow['sub_fisting'] > 4: $csell_fisting = 'I’m not surprised: she clearly has been fisted many times. Inseminations will be much easier for her!'

if cow['mood'] = 0: $csell_mood = 'Hmm, she seems calm. We do not like depressive cows, it can be disastrous for their productivity.'
if cow['mood'] = 1: $csell_mood = 'Hmm, she seems calm. We do not like depressive cows, it can be disastrous for their productivity.'
if cow['mood'] = 2: $csell_mood = 'It seems that you have a pleased cow: it’s a good point, they always are a bit more productive.'
if cow['mood'] = 3: $csell_mood = 'It seems that you have a pleased cow: it’s a good point, they always are a bit more productive.'
if cow['mood'] = 4: $csell_mood = 'She looks really happy with her fate, it’s enjoyable to see. Happiness is good for business, in a farm.'
if cow['mood'] = 5: $csell_mood = 'She looks really happy with her fate, it’s enjoyable to see. Happiness is good for business, in a farm.'
if cow['mood'] = -1: $csell_mood = 'She looks pretty sad... Not a big deal, but happy cows always are more productive, you see?'
if cow['mood'] = -2: $csell_mood = 'She looks pretty sad... Not a big deal, but happy cows always are more productive, you see?'
if cow['mood'] = -3: $csell_mood = 'She looks pretty sad... Not a big deal, but happy cows always are more productive, you see?'
if cow['mood'] = -4: $csell_mood = 'Well... This slave is depressed... You know, it’s bad for business, it can impacts very badly the productivity of our cows.'
if cow['mood'] = -5: $csell_mood = 'Well... This slave is depressed... You know, it’s bad for business, it can impacts very badly the productivity of our cows.'

if cow['angst'] = 0: $csell_angst = 'Anyway, she does not look hopeless at all...'
if cow['angst'] > 0: $csell_angst = 'Clearly she’s in despair... Nothing is more dangerous than angst. I can take her, but we will have to watch her closely.'
if cow['angst'] > 3: $csell_angst = 'And she’s consumed by angst... I don’t know how long she will endure like this... It will greatly impact her price, sir-trainer.'

if cow['fear'] < 2: $csell_fear = 'Ah, but she’s not afraid, that’s better, even if fear isn’t as disastrous as angst for cattle productivity.'
if cow['fear'] > 1: $csell_fear = 'Ah, and she looks afraid. Not a big deal, but it can impact her milk production a bit...'
if cow['fear'] > 3: $csell_fear = 'Ah, and it’s obvious that she’s terrified! Not good, it will lower her productivity, sir-trainer...'

if cow['cowSK_affinity'] > 0: $csell_affinity = 'I saw that your slave looks quite interested in this place: perhaps she has some..."affinity" with being treated like a cow. It only can add to her price.'
if $cow_psy_status = 'broken': $csell_broken = 'One last thing: sorry sir-trainer, but I noted that your slave’s mind is broken... In fact that’s the first thing I saw when you brought her to me. She could be productive enough to interest us, but she’s worth half her real price, in this state. What a shame...'

if cowprice < 1800: $cow_estimate = 'I can buy this girl, but to be honest, sir-trainer, she will not be very profitable... Perhaps she will never be a good cow. I can only offer you <<cowprice>> sparks for her.'
if cowprice >= 1800: $cow_estimate = 'This is standard cattle for me, so yes, we have some room for her, sir-trainer. I can give you <<cowprice>> sparks: a common sum of money for a common cow.'
if cowprice > 2600: $cow_estimate = 'You are bringing us a good cow, sir-trainer! She will be quite a bit productive. That’s why I can offer you <<cowprice>> sparks for her.'
if cowprice > 3500: $cow_estimate = 'I need this girl: we rarely see cows as productive as she is. I can offer you <<cowprice>> sparks: I think the public farm is the best place for her, given her "qualities."'

$cow_auction[1]= '  Jarik takes away <<$cow_name>> for a fair amount of time. He finally comes back with your slave: it seems that he was testing her self-confidence in a livestock farming environment.'
$cow_auction[2]= '  [Jarik]
- <<$csell_age>><<$csell_cowSK>>'
$cow_auction[3]= '  The minotaur squeezes her nipples and pats her hips:
  [Jarik]
- <<$csell_boobs>><<$csell_fat>> Oh, and I made her run a bit: <<$csell_stamina>>'
$cow_auction[4]= '  [Jarik]
- Concerning her character,<<$csell_ego>> Hmm, something else:<<$csell_pride>>'
$cow_auction[5]= '  [Jarik]
- <<$csell_instinct>> <<$csell_custom>>'
$cow_auction[6]= '  Jarik ask you about your slave’s skills as a domestic animal or a horse:
  [Jarik]
- <<$csell_pet>>'
$cow_auction[7]= '  [Jarik]
- <<$csell_xeno>>'
$cow_auction[8]= '  Jarik then has your slave spread her legs and he inspects her pussy - with eyes and fingers. <<$cow_name>> softly moans.
  [Jarik]
- <<$csell_virginity>> <<$csell_fisting>>'
$cow_auction[9]= '  The minotaur finally stands up, adding:
  [Jarik]
- <<$csell_mood>> <<$csell_angst>> <<$csell_fear>>'
$cow_auction[10]= '  <<$csell_affinity>> <<$csell_broken>>
  Jarik gestures you towards the exit, and you both leave the cowshed.'
$cow_auction[11]= '  Jarik slowly shakes his big head while he’s mentally estimating the price of your cow. He finally announces his price:
  [Jarik]
- <<$cow_estimate>>'

--- $cow_price ---------------------------------


code:
# $difficulty_setting
!Difficulty Setting - created by crushboss

!Easy difficulty setting for tutorial / demo mode - crushboss
if exam_in_progress = 1: difficulty_setting = 1

!Obedience adjustments for difficulty setting - crushboss

!ImperatorAugustus: converted to dynamic function, apply same formula for all slaves (including inactive ones in case they are taken out of storage)

dynamic $do_for_each_slave_in_list, '$set_obedience_difficulty', '$all_slave_characters' &! see #static_base

--- $difficulty_setting ---------------------------------

repo_name: Tcallas/game

license: unknown


code:
# $end_day_variable_reset
!Clean slate for new day - sanity check - crushboss (called from main_menu and end_day_screen)
!Created by crushboss

$end_day_variable_reset_for_all_slaves = {
	!do not reset daily reward count here; it is handled in next_day - ImperatorAugustus

	!reset arena participation flag so characters iced on arena day and thawed on next arena day can fight - ImperatorAugustus
	dynslave['gladiatrix_contest'] = 0

	!reset daily interaction counters
	killvar 'dynslave_already_done_today'
	killvar 'dynslave_already_sex_today'

	!reset daily accumulated rest rewards
	dynslave['well_rested'] = 0

	!reset daily rule following counters
	dynslave['num_rules_broken'] = 0
	dynslave['num_rules_wanttobreak'] = 0
	dynslave['silence_rule_broken'] = 0
	dynslave['humility_rule_broken'] = 0
	dynslave['no_shit_rule_broken'] = 0
	dynslave['pet_rule_broken'] = 0
	dynslave['blowjob_rule_broken'] = 0
	dynslave['urinal_rule_broken'] = 0
	dynslave['toilet_rule_broken'] = 0
	dynslave['v_balls_rule_broken'] = 0

	!reset not-more-than-once-a-day notification flags
	dynslave['nearly_fainted'] = 0
	dynslave['stamina_fainted'] = 0
	dynslave['exhaustion_fainted'] = 0

	!reset time_in_barn counter for non-livestock characters (farmhand included)
	if arrpos('$livestock_slave_characters', 'dynslave') = -1: dynslave['time_in_barn'] = 0
}

dynamic $do_for_each_slave_in_list, '$end_day_variable_reset_for_all_slaves', '$all_slave_characters'

!Reset tasks already performed (household global counters, not person-specific)
killvar 'already_done_today'
killvar 'city_already_done_today'

cheer_effect = 0
cheer_rate = 0
reasoning_effect = 0
reasoning_rate = 0

free_time = 0
!removed unnecessary rules_count variable clearing (it is reset before use, in next_day/$difficulty_setting) - ImperatorAugustus
slave_will_masturbate = 0
slave_masturbating_anyway = 0
!removed unnecessary *_rule_res variable clearing (they are reset before use, in next_day) - ImperatorAugustus

a = 0
b = 0
c = 0
g = 0
i = 0
s = 0
aaa = 0

npc = 0
skip_to = 0
multiple = 0

stock_sold = 0
auction_phase = 0
haggling_stage = 0
menu_form = 0

fear_resistance = slave["ego"] + rebell[$slave_psy_basic]

interaction = 0
interaction_city = 0
$interaction_type = ''

!add_slave_mood = 0 - globally unused variable - ImperatorAugustus
sin_gained = 0
$praise_type = ''
angst_rise = 0
moral_app = 0
moral_basis = 0
moral_boost = 0
arousal_modifier = 0
slave_fights_back = 0

previous_slave_sin = 0
previous_slave_virtue = 0
sin_gain = 0
sin_gained = 0
slave_beg_for_sex = 0
assistant_beg_for_sex = 0
fog_battle = 0
gladiatrix_contest_count = 1
arena_mode = 0

$special_part = ''

faction_purchase_kamira = 0
faction_purchase_serpis = 0
faction_purchase_taurus = 0
faction_purchase_korvus = 0
faction_purchase_neutral = 0

killvar 'play_sound'
killvar 'sex'
killvar 'sex_num'
killvar 'sex_done_today'
killvar 'sex_done_thisperson'

killvar 'суперудар_сделан'
!killvar '$text'
killvar '$race_winner'
killvar '$fight_return'
killvar '$return_lock'

!sl_txt = 0
!sp_txt = 0
!$refuse_txt = ''
!$msg_txt = ''

--- $end_day_variable_reset ---------------------------------


code:
# $expert_search

dynamic $swap_slave_instances, 'stock', 'saved_stock' &! save existing pending stock if any - ImperatorAugustus

n = rand(3,5)
i = 0
:loop
    i += 1
    match = 0
    gs 'generate_stock'

    if search["age"] = 0:
        match += 1
    else
        if stock["age"] = CONST_INT['young_age']:
            if search["age"] = 4 or search["age"] = 5 or search["age"] = 2: match += 1
        elseif stock["age"] = CONST_INT['loli_age']:
            if search["age"] = 4 or search["age"] = 3: match += 1
        elseif stock["age"] = CONST_INT['milf_age']:
            if search["age"] = 5 or search["age"] = 1: match += 1
        else
            !Debug
            msg 'Error! stock["age"] = <<stock["age"]>>, but should be in [0-2], location = <<$curloc>>'
        end
    end

    if stock["beauty"] >= search["beauty"]: match += 1
    if stock["stamina"] >= search["stamina"]: match += 1
    if stock["sensitivity"] >= search["sensitivity"]: match += 1
    if stock["intellect"] >= search["intellect"]: match += 1
    if stock["temper"] >= search["temper"]: match += 1
    if stock["ego"] >= search["ego"]: match += 1

    if match >= 7:
        search['active'] = 2
        dynamic $swap_slave_instances, 'stock', 'selected' &! move stock slave to expert
    end

if i < n: jump 'loop'

dynamic $swap_slave_instances, 'stock', 'saved_stock' &! restore saved stock - ImperatorAugustus
dynamic $clear_slave_instance, 'saved_stock'

--- $expert_search ---------------------------------


code:
# $food_choice
!TODO: сделать из 5 циклов 1
!Choose a dish for dinner
fridge['none'] = 5
$cooked_meal = 'консервы'
end_rate = 0

!TODO: исправить хардкод - еды 1 уровня 12 штук, и далее по всем уровням
if cooked_food > 0:
	i = 0
	:loop1
		i += 1
		! 1 - 12, т.к. еда первого уровня от 1 до 12
		$try = $meal_id[rand(1, 12)]
		if fridge[$meal_first_ingredient[$try]] > 0 and fridge[$meal_second_ingredient[$try]] > 0 and fridge[$meal_third_ingredient[$try]] > 0 and fridge[$meal_fourth_ingredient[$try]] > 0: $cooked_meal = $try & end_rate = 1
		if $cooked_meal = 'консервы' and i < 30: jump 'loop1'
end

if cooked_food > 1:
	$pre = $cooked_meal
	i = 0
	:loop2
		i += 1
		! 13 - 27, т.к. еда второго уровня от 13 до 27
		$try = $meal_id[rand(13, 27)]
		if fridge[$meal_first_ingredient[$try]] > 0 and fridge[$meal_second_ingredient[$try]] > 0 and fridge[$meal_third_ingredient[$try]] > 0 and fridge[$meal_fourth_ingredient[$try]] > 0: $cooked_meal = $try & end_rate = 2
		if $cooked_meal = $pre and i < 30: jump 'loop2'
end

if cooked_food > 2:
	$pre = $cooked_meal
	i = 0
	:loop3
		i += 1
		! 28 - 43, т.к. еда третьего уровня от 28 до 43
		$try = $meal_id[rand(28, 43)]
		if fridge[$meal_first_ingredient[$try]] > 0 and fridge[$meal_second_ingredient[$try]] > 0 and fridge[$meal_third_ingredient[$try]] > 0 and fridge[$meal_fourth_ingredient[$try]] > 0: $cooked_meal = $try & end_rate = 3
		if $cooked_meal = $pre and i < 30: jump 'loop3'
end

if cooked_food > 3:
	$pre = $cooked_meal
	i = 0
	:loop4
		i += 1
		! 44 - 59, т.к. еда четвертого уровня от 44 до 59
		$try = $meal_id[rand(44, 59)]
		if fridge[$meal_first_ingredient[$try]] > 0 and fridge[$meal_second_ingredient[$try]] > 0 and fridge[$meal_third_ingredient[$try]] > 0 and fridge[$meal_fourth_ingredient[$try]] > 0: $cooked_meal = $try & end_rate = 4
		if $cooked_meal = $pre and i < 30: jump 'loop4'
end

if cooked_food > 4:
	$pre = $cooked_meal
	i = 0
	:loop5
		i += 1
		! 60 - 74, т.к. еда пятого уровня от 60 до 74
		$try = $meal_id[rand(60, 74)]
		if fridge[$meal_first_ingredient[$try]] > 0 and fridge[$meal_second_ingredient[$try]] > 0 and fridge[$meal_third_ingredient[$try]] > 0 and fridge[$meal_fourth_ingredient[$try]] > 0: $cooked_meal = $try & end_rate = 5
		if $cooked_meal = $pre and i < 30: jump 'loop5'
end

fridge[$meal_first_ingredient[$cooked_meal]] -= 1
fridge[$meal_second_ingredient[$cooked_meal]] -= 1
fridge[$meal_third_ingredient[$cooked_meal]] -= 1
fridge[$meal_fourth_ingredient[$cooked_meal]] -= 1
cooked_food = end_rate

--- $food_choice ---------------------------------


code:
# $furniture_list
!Create a list of furniture in the house
$furniture_list = ''
house_items = 0

if art_material > 0:
	$furniture_list += 'Art Material х<<art_material>>
'
	house_items += art_material
end

if percussion > 0:
	$furniture_list += 'Percussion Instrument х<<percussion>>
'
	house_items += percussion
end

if woodwind > 0:
	$furniture_list += 'Woodwind Instrument х<<woodwind>>
'
	house_items += woodwind
end

if violin > 0:
	$furniture_list += 'String Instrument х<<violin>>
'
	house_items += violin
end

if piano > 0:
	$furniture_list += 'Piano х<<piano>>
'
	house_items += piano
end

$furniture_list += '
'

if vibrator = 1:
	$furniture_list += 'Vibrator x1
'
	house_items += 0
end

if inventory['vaginal_balls'] = 1:
	$furniture_list += 'V-balls x1
'
	house_items += 0
end

if inventory['anal_plug'] = 1:
	$furniture_list += 'Anal Pear x1
'
	house_items += 0
end

if inventory['secure_gag'] = 1:
	$furniture_list += 'Reliable Gag x1
'
	house_items += 0
end

if inventory['chastity_belt'] = 1:
	$furniture_list += 'Chastity Belt x1
'
	house_items += 0
end

if inventory['deprivation_suit'] = 1:
	$furniture_list += 'Deprivation Suit x1
'
	house_items += 2
end

if inventory['pissuar_stable'] = 1:
	$furniture_list += 'Urinal Rack x1
'
	house_items += 5
end

if inventory['toilet_stable'] = 1:
	$furniture_list += 'Toilet Seat x1
'
	house_items += 10
end

if inventory['dummy'] > 0:
	a = 6*inventory['dummy']
	$furniture_list += 'Dummy [<>]
'
	house_items += a
end

if inventory['heads'] > 0:
	b = 2*inventory['heads']
	$furniture_list += 'Heads [<>]
'
	house_items += b
end
!Strec - jon_UIadds addition (begin)
if inventory['stethoscope'] = 1:
	$furniture_list += 'Stethoscope x1
'
	house_items += 1
end
!Strec - jon_UIadds addition (end)

--- $furniture_list ---------------------------------


code:
# $gladiator_fight_start
!START OF THE GLADIATRIX FIGHT
!Overhauled by crushboss

$fight_return = 'Start'
arena_mode = 1

base_str = slave['stamina'] + slave['gladiatrix_affinity']
if slave['age'] = CONST_INT['loli_age']: base_str = (2*base_str)/3 + slave['gladiatrix_affinity']
if slave['age'] = CONST_INT['milf_age']: base_str += 1
base_flagelation = slave['gladiatrix'] + slave['gladiatrix_affinity']
сила = slave['gladiatrix'] + slave['gladiatrix_affinity']
ловкость = slave['gladiatrix'] + slave['gladiatrix_affinity']
восприятие = slave['gladiatrix'] + slave['gladiatrix_affinity']
if slave['gladiatrix_affinity_revealed'] = 0: slave['gladiatrix_affinity_revealed'] = 1

суперудар_сделан[1] = iif(slave['gladiatrix'] > 2, 0, 1)

!Load Combat Database
gs '#тексты_движка'
gs '#противники'
gs '#суперудары'
gs '#боевые_предметы'

!Interface
gs 'раскладка_бой'

$combatant_ava = '<<$slave[''ava'']>>.png'
$combatant_name = $slave_name
$броня = $armor[$g_type]
$оружие = $style_wpn[$g_type]
$вторичный = $style_freehand[$g_type]

!Set base combat attributes and results - fixed and improved - crushboss
макс_здоровье_игрока = slave['stamina'] * 10 - slave_rate['wounds']
if slave['gladiatrix_affinity'] > 0: макс_здоровье_игрока = slave['stamina']*10
if slave['age'] = CONST_INT['loli_age']: макс_здоровье_игрока -= макс_здоровье_игрока/3
if slave['age'] = CONST_INT['milf_age']: макс_здоровье_игрока += slave['stamina']*2
if макс_здоровье_игрока < 1: макс_здоровье_игрока = 1
здоровье_игрока = макс_здоровье_игрока
макс_выносливость_игрока = 50 + (slave['energy']*5)
if slave['gladiatrix_affinity'] > 0: макс_выносливость_игрока = 75 + (slave['energy']*5)
выносливость_игрока = макс_выносливость_игрока
норм_дух_игрока = slave['ego']*10 + slave['gladiatrix']*10
if slave['gladiatrix_affinity'] > 0: норм_дух_игрока += slave['ego']*10
дух_игрока = норм_дух_игрока
сила_передышки = 10
slave['calories'] -= 5
slave_rate['hygiene'] += 40
slave_rate['sensitivity'] -= 5

dynamic $броня_надеть[$броня]
dynamic $броня_эффект[$броня]

!Cycle information about mobs-enemies
i = 0
:loop
	if i < количество_врагов:
		i += 1
		$имя_врага[i] = $название_моба[$враг[i]]
		$склонение_врага[i] = $склонение_моба[$враг[i]]
		$класс_врага[i] = $класс_моба[$враг[i]]
		$труп_врага[i] = $смерть[$враг[i]]
		$тело_врага[i] = $отключка[$враг[i]]
		$беглец[i] = $бегство[$враг[i]]

		макс_здоровье_врага[i] = базовое_здоровье[$враг[i]]
		здоровье_врага[i] = базовое_здоровье[$враг[i]]
		выносливость_врага[i] = базовая_выносливость[$враг[i]]
		дух_врага[i] = базовый_дух[$враг[i]]
		вред_врага[i] = базовый_вред[$враг[i]]
		случай = rand(1,3)
		if случай = 1: $защита[i] = 'блок'
		if случай = 2: $защита[i] = 'контратака'
		if случай = 3: $защита[i] = 'уклонение'
		враг[i] = 1
		jump 'loop'
	end

текущий = 1
$суперудар[1] = $gt_spm[$g_type]

gs 'боевое_меню'
gt 'боевой_интерфейс'
--- $gladiator_fight_start ---------------------------------


code:
# $gladiator_setup
!Calculation of input for gladiatrix combat
!Improved - crushboss

!Reset Combat Variables at the start of a new Gladiatrix Contest - crushboss
gs '$combat_variable_reset'
sp_txt = 0
количество_врагов = 1
superviser_message = 0
a = 0
killvar '$extra_special_active'
killvar '$extra_special_used'
killvar '$враг'
killvar '$ge'

if slave['arena_level'] < 1:
	a = rand(1,4)
	if a = 1: $ge = 'dimaher_a'
	if a = 2: $ge = 'hoplite_a'
	if a = 3: $ge = 'secutor_a'
	if a = 4: $ge = 'kimerian_a'
	superviser_message = 1
end

if slave['arena_level'] = 1:
	a = rand(1,4)
	if a = 1: $ge = 'dimaher_b'
	if a = 2: $ge = 'hoplite_b'
	if a = 3: $ge = 'secutor_b'
	if a = 4: $ge = 'kimerian_b'
	superviser_message = 2
end

if slave['arena_level'] = 2:
	a = rand(1,4)
	if a = 1: $ge = 'dimaher_c'
	if a = 2: $ge = 'hoplite_c'
	if a = 3: $ge = 'secutor_c'
	if a = 4: $ge = 'kimerian_c'
	superviser_message = 3
end

if slave['arena_level'] = 3:
	a = rand(1,4)
	if a = 1: $ge = 'dimaher_d'
	if a = 2: $ge = 'hoplite_d'
	if a = 3: $ge = 'secutor_d'
	if a = 4: $ge = 'kimerian_d'
	superviser_message = 4
end

if slave['arena_level'] >= 4 and $slave['trademark_style'] = '':
	a = rand(1,4)
	if a = 1: $ge = 'dimaher_e'
	if a = 2: $ge = 'hoplite_e'
	if a = 3: $ge = 'secutor_e'
	if a = 4: $ge = 'kimerian_e'
	superviser_message = 5
end

if slave['arena_level'] > 4 and $slave['trademark_style'] ! '':
	if challenge_type = 1:
		a = rand(1,5)
		!Added code to have the Vatican Champion appear sooner to help avoid the Vatican Champion damage bug - crushboss
		if trophy_vatican = 0 and a ! 5:
			b = rand(1,10)
			if b < 6: a = 5
			b = 0
		end
		if a = 1: $ge = 'champion_kamira'
		if a = 2: $ge = 'champion_corvus'
		if a = 3: $ge = 'champion_serpis'
		if a = 4: $ge = 'champion_taurus'
		if a = 5: $ge = 'champion_vatican'
		superviser_message = 6
	end
	if challenge_type = 2:
		количество_врагов = 5
		$ge = 'fugituive_a'
		$ge2 = 'fugituive_b'
		$ge3 = 'fugituive_c'
		$ge4 = 'fugituive_d'
		$ge5 = 'fugituive_e'
		superviser_message = 7
	end
	if challenge_type = 3:
		$ge = 'исчадие_арены'
		superviser_message = 8
	end
	if challenge_type = 4:
		$ge = 'champion_absolute'
		superviser_message = 9
	end
end

if $g_type = "retiarius":
	$extra_special_active = 'content/pic/buttons/net_active.png'
	$extra_special_used = 'content/pic/buttons/net_used.png'
end

if $g_type = "flagrius":
	$extra_special_active = 'content/pic/buttons/whip_active.png'
	$extra_special_used = 'content/pic/buttons/whip_used.png'
end

if $g_type = "dimacherus" or $g_type = '':
	$g_type = "dimacherus"
	$extra_special_active = 'content/pic/buttons/dual_active.png'
	$extra_special_used = 'content/pic/buttons/dual_used.png'
end

if $g_type = "hoplomachus":
	$extra_special_active = 'content/pic/buttons/shield_active.png'
	$extra_special_used = 'content/pic/buttons/shield_used.png'
end

if $g_type = "kimerian":
	$extra_special_active = 'content/pic/buttons/heavy_active.png'
	$extra_special_used = 'content/pic/buttons/heavy_used.png'
end

interaction_city = 12801
$враг[1] = $ge
$враг[2] = $ge2
$враг[3] = $ge3
$враг[4] = $ge4
$враг[5] = $ge5

gt 'interaction_city'

--- $gladiator_setup ---------------------------------


code:
# $guild_auction
!Auction of branded slaves
!TODO: pre-seed random rolls at decade start
gs '$slave_price', 'slave'
auction_count = 10
killvar '$auction_flow'
u = 2

!Determination of the bidders
killvar '$auction_participant'
killvar 'random_demand'
n = arrsize('$auction_buyer')
i = 0
e = 0
:auction_participation_loop
	i += 1
	if npc_participation_chance[$auction_buyer[i]] > 0:
		e += 1
		$auction_participant[e] = $auction_buyer[i]
		!To make the NPCs not quite so static... maybe they are hard up this decade, or have been saving up
		!This is an auction after all, anything goes.  Watch a few seasons of Storage Wars - Frobozz
		a = ((day * e - i) mod 9) &! deterministic pseudo-random numbers instead of rand(0,8)
		if a > 0 and a < 10: random_demand[e] = demand_rating[$auction_participant[e]] + (a - 4)
		!0 is just no interest today, 10 is sky is the limit... dig into savings to get something great.
		if random_demand[e] < 0 or a = 0: random_demand[e] = 0
		if random_demand[e] > 8 or a = 8: random_demand[e] = 8
	end
if i < n-1: jump 'auction_participation_loop'

n = arrsize ('$auction_participant')
n -= 1
i = 0
:interest_loop
	i += 1
	if slave_specialisation[$interesting_specialisation[$auction_participant[i]]] = 1:
		a = ((day * n + i) mod 18) &! deterministic pseudo-random numbers instead of rand(0,17)
		a += demand_rating[$auction_participant[i]]
		participant_interest[$auction_participant[i]] = charm + slave['prestige'] - a
		!If the product meets or exceeds the participants standards, much higher chance theyll want it and the only issue is that of money.
		if demand_rating[$auction_participant[i]] <= rating:
			rises = participant_interest[$auction_participant[i]]
			!Lets make this scale like the routine below.  Levels above expectation should scale accordingly. - Frobozz
			r = rating - demand_rating[$auction_participant[i]]
			rises += r
			!Now, some high-rollers wont feel like spending a lot today, and likewise some smaller players may have a nest egg saved up for a good product.
			b = auction_increment[random_demand[i]] * rises
			cap_summ[$auction_participant[i]] = discount_price[rating] + b/2
		end
		!If the product is below the participants standards, the participant probably wont want it, but there is a possibility.
		if demand_rating[$auction_participant[i]] > rating and participant_interest[$auction_participant[i]] > 0:
			rises = participant_interest[$auction_participant[i]]
			r = demand_rating[$auction_participant[i]] - rating
			if r = 1: rises += 8
			if r = 2: rises += 4
			if r = 3: rises += 2
			if r > 3: rises += 1
			b = auction_increment[rating] * rises
			cap_summ[$auction_participant[i]] = auction_price[rating] + b/2
		end
	end
if i < n: jump 'interest_loop'

bank_size = max(15, auction_increment[rating]) &! minimum value of a slave is 15 sparks (same as what Farid pays for F- rating) - ImperatorAugustus
$auction_flow[1] = '  Middleman offers a starting bid of <<bank_size>> sparks. If no one bids higher, <<$slave_name>> goes to him at that price.'
$auc_winner = 'Middleman'
y = 0
i = 0
a = 0
u = 1
x = 1
:torg_loop
	i += 1
	if bank_size < cap_summ[$auction_participant[i]] and i ! y:
		bet_multipler = 1 + ((day * u + i) mod 2) &! deterministic pseudo-random numbers instead of rand(1,3)
		bet_size = auction_increment[rating] * bet_multipler
		if demand_rating[$auction_participant[i]] > rating:
			bet_size += auction_random[rating]
		else
			bet_size += auction_random[demand_rating[$auction_participant[i]]]
		end
		bet_size -= ((day * rating + u * x) mod i) * 5
		if bet_size > 0:
			bank_size += bet_size
			$auction_flow[u] = '  <<$npc_name[$auction_participant[i]]>> bids <<bet_size>> more and increases the price to <<bank_size>>.'
			$auc_winner = $npc_name[$auction_participant[i]]
			y = i
			x = 1
			u += 1
			i = 0
			jump 'torg_loop'
		end
	end
	if i < n: jump 'torg_loop'

	$auction_hammer[1] = '  [AUCTIONEER]
- <<bank_size>> sparks, one!'
	$auction_hammer[2] = '  [AUCTIONEER]
- <<bank_size>> sparks, two! Perhaps this is the final price?'
	$auction_hammer[3] = '  [AUCTIONEER]
- <<bank_size>> sparks, three! Sold!!! Final price: <<bank_size>>. Buyer: <<$auc_winner>>.'
	$auction_flow[u] = $auction_hammer[x]
	i = 0
	u += 1

if x < 3:
	x += 1
	jump 'torg_loop'
end
sparks_get = bank_size
master_moodlet['pos_deal'] = 3
guild_reputation_rate += rating/3
interaction_city = 931
gt 'interaction_city'
--- $guild_auction ---------------------------------


code:
# $menu
! Creates a link to something
! arg1 = ID
! arg2 = EXEC
! arg3 = GT
if $args[0] = 'get_link':
	$menu_exec = ''
	$result = $menu_exec + args[1] + $menu_goto_form
end

! Creates a tooltip with top offset 43 pixels
if $args[0] = 'tooltip_menu':
	$top = 43 + (args[2] * 62)
	$result = '

'
end

! Writes a complete menu item / list item, exec command and goto location
! arguments: 1 = menu_item_index, 2 = location id, 3 = EXEC, 4 = GT, 5 = menu item text, 6 = tooltip text
if $args[0] = 'goto':
	menu_item_counter += 1
	$text_display += $args[1] + func('$menu', 'get_link',  args[2],  $args[3], $args[4]) + $args[5] + '
'
	$text_display += func('$menu', 'tooltip_menu',  'tooltip', menu_item_counter, $args[6])
end
if $args[0] = 'gotobarn':
	menu_item_counter += 1
	$text_display += $args[1] + func('$menu', 'get_link',  args[2],  $args[3], $args[4]) + $args[5] + '
'
end
if $args[0] = 'goto_2':
	menu_item_counter += 1
	$text_display += $args[1] + func('$menu', 'get_link',  args[2],  $args[3], $args[4]) + $args[5] + '
'
end
if $args[0] = 'goto_city':
	menu_item_counter += 1
	$text_display += $args[1] + func('$menu', 'get_link',  args[2],  $args[3], $args[4]) + $args[5] + '
'
end
if $args[0] = 'goto_sex_options':
	menu_item_counter += 1
	$sex_menu += $args[1] + func('$menu', 'get_link',  args[2],  $args[3], $args[4]) + $args[5] + '
'
end

! Writes a complete menu item / list item, only exec command
! arguments: 1 = menu_item_index, 2 = EXEC, 3 = menu item text, 4 = tooltip text
if $args[0] = 'exec':
	menu_item_counter += 1
	$text_display += $args[1] +'' + $args[3] + '
'
	$text_display += func('$menu', 'tooltip_menu', 'tooltip', menu_item_counter, $args[4])
end

if $args[0] = 'exec_options':
	menu_item_counter += 1
	$text_display += $args[1] + '' + $args[3] + '
'
end

if $args[0] = 'exec_sex_options':
	menu_item_counter += 1
	$sex_menu += $args[1] + '' + $args[3] + '
'
end

if $args[0] = 'join_battle':
	$text_display += $args[1]
	$text_display += {}
	$text_display += $args[2] + '
'
end

if $args[0] = 'empty_item':
	for i = 1 to args[1] step 1: menu_item_counter += 1 & $text_display += '

'
end

if $args[0] = 'spacer':
	$text_display += '

'
end

if $args[0] = 'sex_empty_item':
	for i = 1 to args[1] step 1: menu_item_counter += 1 & $sex_menu += '

'
end

if $args[0] = 'menu_form':
	func('$menu', 'goto',  $args[1], args[2], 'menu_form', 'menu_form', $args[3], $args[4])
end

if $args[0] = 'barn_form':
	func('$menu', 'goto',  $args[1], args[2], 'barn_interface', 'barn_interface', $args[3], $args[4])
end

if $args[0] = 'menu_form_2':
	func('$menu', 'goto_2',  $args[1], args[2], 'menu_form', 'menu_form', $args[3])
end

if $args[0] = 'interaction_city':
	func('$menu', 'goto_city',  $args[1], args[2], 'interaction_city', 'interaction_city', $args[3])
end

if $args[0] = 'interaction':
	func('$menu', 'goto_city',  $args[1], args[2], 'interaction', 'interaction', $args[3])
end

if $args[0] = 'sex_interaction':
	func('$menu', 'goto_sex_options',  $args[1], args[2], 'sex_interaction', 'sex_interaction', $args[3])
end

if $args[0] = 'city_form':
	func('$menu', 'goto_city',  $args[1], args[2], 'city_form', 'city_menu_form', $args[3])
end

if $args[0] = 'location_gray':
	func('$menu', 'goto_city', $args[1], args[2], empty, empty, $args[3])
end

if $args[0] = 'location_gray_tooltip':
	func('$menu', 'goto_city', $args[1], args[2], empty, empty, $args[3])
	$text_display += func('$menu', 'tooltip_menu',  'tooltip', menu_item_counter, $args[4])
end

if $args[0] = 'menu_form_gray':
	func('$menu', 'goto', $args[1], args[2], empty, empty, $args[3], $args[4])
end

if $args[0] = 'sex_location_gray':
	func('$menu', 'goto_sex_options', $args[1], args[2], empty, empty, $args[3])
end

if $args[0] = '===BEGIN===':
	$text_display += '

'
	menu_item_counter = -1
end

if $args[0] = '===END===':
	$text_display += '

'
	menu_item_counter = -1
end

if $args[0] = '===SEX_BEGIN===':
	$sex_menu += '

'
	menu_item_counter = -1
end

if $args[0] = '===SEX_END===':
	$sex_menu += '

'
	menu_item_counter = -1
end

if $args[0] = '===BEGIN_H_MENU===':
	$text_display += '

'
	menu_item_counter = -1
end

--- $menu ---------------------------------


code:
# $mod_global_drop
! decrease all moodlet magnitudes (both positive and negative) for assistant and prisoner by one
! called by next_day

i = arrsize('$slave_bad_mood')
:loop
	$curmod = $slave_bad_mood[i]
	if assistant_state > CONST_INT['no_slave']: assistant[$curmod] = max(0, assistant[$curmod] - 1)
	if prisoner_state > CONST_INT['no_slave']: prisoner[$curmod] = max(0, prisoner[$curmod] - 1)
	i -= 1
if i > 0: jump 'loop'

i = arrsize('$slave_good_mood')
:loop1
	$curmod = $slave_good_mood[i]
	if assistant_state > CONST_INT['no_slave']: assistant[$curmod] = max(0, assistant[$curmod] - 1)
	if prisoner_state > CONST_INT['no_slave']: prisoner[$curmod] = max(0, prisoner[$curmod] - 1)
	i -= 1
if i > 0: jump 'loop1'

--- $mod_global_drop ---------------------------------


code:
# $mod_master_drop
!Decrease magnitude of positive moodlets of master by specified number (args[0])

i = arrsize('$master_good_mood')
:loop
	$curmod = $master_good_mood[i]
	master_moodlet[$curmod] = max(0, master_moodlet[$curmod] - args[0])
	i -= 1
if i > 0: jump 'loop'

--- $mod_master_drop ---------------------------------


code:
# $mod_master_rise
!Decrease magnitude of negative moodlets of master by specified number (args[0])
i = arrsize('$master_bad_mood')
:loop
	$curmod = $master_bad_mood[i]
	master_moodlet[$curmod] = max(0, master_moodlet[$curmod] - args[0])
	i -= 1
if i > 0: jump 'loop'

--- $mod_master_rise ---------------------------------


code:
# $mood_drop
!Decrease magnitude of positive moodlets of specified slave ($args[0]) by specified number (args[1])

i = arrsize('$slave_good_mood')
:mood_drop_loop
	i -= 1
	$curmod = $slave_good_mood[i]
	dynamic "<<$args[0]>>[$curmod] = max(0, <<$args[0]>>[$curmod] - <<args[1]>>)"
if i > 1: jump 'mood_drop_loop'

--- $mood_drop ---------------------------------


code:
# $mood_rise
!Decrease magnitude of negative moodlets of specified slave ($args[0]) by specified number (args[1])

i = arrsize('$slave_bad_mood')
:mood_rise_loop
	i -= 1
	$curmod = $slave_bad_mood[i]
	dynamic "<<$args[0]>>[$curmod] = max(0, <<$args[0]>>[$curmod] - <<args[1]>>)"
if i > 1: jump 'mood_rise_loop'

--- $mood_rise ---------------------------------


code:
# $moodlets_account
!refreshes master_mood (and $master_mood_list diary mood description texts) for master
!derives mood from active moodlets (any with positive magnitudes) and mood_master_rate
!called from $calculate_attributes which is called from $newloc

master_mood = 0
!note that we use a different variable (master_mood) to store the calculated numeric mood value vs. the array of numeric moodlet magnitudes (master_moodlet)
!this is because mixing numeric and string indices in the same variable can cause unexpected results (string indices can map to the same slots as numeric indices)

!AddOn - makes no sense to reset on every $newloc trigger
!mood rate was being reset every time - changed to re-apply on each refresh and clear in next_day - ImperatorAugustus
if master_mood_rate ! 0: master_mood += master_mood_rate / 10 &! note: mood rate can be negative

!construct a linebreak-separated string listing mood descriptions for active moodlets and apply mood +/- adjustments
$master_mood_list = ''

n = arrsize('$master_good_mood')
i = 0 &! array starts from index 0
:master_mood_loop1
	$curmod = $master_good_mood[i]
	if master_moodlet[$curmod] > 0:
		$master_mood_list += "   <<$mood_description[$curmod]>>
"
		master_mood += 1
	end
	i += 1
if i < n: jump 'master_mood_loop1'

!extra line break between good mood descriptions and bad mood descriptions
if $master_mood_list ! '': $master_mood_list += '
'

n = arrsize('$master_bad_mood')
i = 0 &! array starts from index 0
:master_mood_loop2
	$curmod = $master_bad_mood[i]
	if master_moodlet[$curmod] > 0:
		$master_mood_list += "   <<$mood_description[$curmod]>>
"
		master_mood -= 1
	end
	i += 1
if i < n: jump 'master_mood_loop2'

! keep mood within [-5, +5] range
if master_mood > 5:  master_mood = 5
if master_mood < -5:  master_mood = -5

if debug_master_mood = 1: msg 'mood rate=<<master_mood_rate>>, mood=<<master_mood>>
<<$master_mood_list>>'

--- $moodlets_account ---------------------------------


code:
# $newloc
!Location handler transitions
!Overhauled by crushboss
!AddOnn - disabled wizard_mode check to enable in story mode via options menu
if $master_name ! 'Старый Охотник': wizard_mode = 0

!AddOn - Version check
$title_fix = 'Jack-o-nine-tails v2.2 Dev Version'
if saved_game_loaded > 0 or $ongload = '' or $game_ver ! $title_fix:
	killvar 'saved_game_loaded'
	gs '$addon', 'update', 'full'
end

if debug_newloc = 1: msg '$newloc: $curloc = <<$curloc>>'

!Evaluate slave achievements
if slave_state > CONST_INT['no_slave']:
	if slave['selfesteem'] > 0 and slave['virtue'] > 0:
		slave['virtue'] = 5
		if slave['selfesteem_revealed'] = 0: slave['selfesteem_revealed'] = 1
	end
	if slave['selfesteem'] < 0 and slave['sin'] > 0:
		slave['sin'] = 5
		if slave['selfesteem_revealed'] = 0: slave['selfesteem_revealed'] = 1
	end
	if slave['virtue'] > 0: eval = slave['virtue']
	if slave['sin'] > 0: eval = 5 + slave['sin']
	if slave['sin'] = 0 and slave['virtue'] = 0: eval = 0
end

! standard of living is capped by residence prestige (currently ranges [-1, 4], therefore +2) - ImperatorAugustus
if master_wealth_target > estate_prestige[$estate] + 2: master_wealth_target = estate_prestige[$estate] + 2
if master_wealth > estate_prestige[$estate] + 2: master_wealth = estate_prestige[$estate] + 2
if day = 1: master_wealth = master_wealth_target &! allow immediate changes on day 1

!Added behavior and rules for extended rental - crushboss
if pen ! 1:
	pet_tentacle = 0
	tentacle_hp = 0
	tentacle_size = 0
	tentacle_state = 0
end

if pet_tentacle ! 1:
	pet_tentacle = 0
	tentacle_state = 0
	tentacle_hp = 0
	tentacle_size = 0
else
	if spawn_milked = 0: tentacle_state = 1
	if spawn_milked > tentacle_size: tentacle_state = 2
end

if barn ! 1:
	svine = 0
else
	svine = 1
end

if dungeon ! 1:
	arachnidSpider = 0
	polypusvermin = 0
else
	arachnidSpider = 1
	polypusvermin = 1
end

!Add data for extended rental cheat - crushboss
if extended_rental_cheat > 0:
	!Extended Rental
	lab = 1
	boudoir = 1
	dungeon = 1
	barn = 1
	bath = 1
	kitchen = 1
	pen = 1
	svine = 1
	arachnidSpider = 1
	polypusvermin = 1

	!Estate Interiors
	$study = 'classic'
	$interior_study_large['classic'] = 'interiors\classic_study_large'
	$interior_study['classic'] = 'interiors\classic_study'
	$interior_study_info['classic'] = '   '
	$bg['study'] = $interior_study[$study]
	$bg['home_lux'] = $interior_study_large[$study]
	$place_name['study'] = $estate_study_name[$estate]
	$place_location['study'] = $estate_study_location[$estate]
	$place_info['study'] = $interior_study_info[$study]

	$bed = 'stylish'
	$interior_bed_large['stylish'] = 'interiors\stylish_bed_large'
	$interior_bed['stylish'] = 'interiors\stylish_bed'
	$interior_bed_info['stylish'] = '   '
	$bg['bedroom'] = $interior_bed[$bed]
	$bg['bedroom_lux'] = $interior_bed_large[$bed]
	$place_name['bedroom'] = $estate_bed_name[$estate]
	$place_location['bedroom'] = $estate_bed_location[$estate]
	$place_info['bedroom'] = $interior_bed_info[$bed]

	$bath = 'gothic'
	$interior_bath_large['gothic'] = 'interiors\gothic_bath_large'
	$interior_bath['gothic'] = 'interiors\gothic_bath'
	$interior_bath_info['gothic'] = '   '
	$bg['bathroom'] = $interior_bath[$bath]
	$bg['bathroom_lux'] = $interior_bath_large[$bath]
	$place_name['bathroom'] = $estate_bath_name[$estate]
	$place_location['bathroom'] = $estate_bath_location[$estate]
	$place_info['bathroom'] = $interior_bath_info[$bath]

	$dungeon = 'executor'
	$interior_dungeon_large['executor'] = 'interiors\executor_dungeon_large'
	$interior_dungeon['executor'] = 'interiors\executor_dungeon'
	$interior_dungeon_info['executor'] = '   '
	$bg['dungeon'] = $interior_dungeon[$dungeon]
	$bg['dungeon_lux'] = $interior_dungeon_large[$dungeon]
	$place_name['dungeon'] = $estate_dungeon_name[$estate]
	$place_location['dungeon'] = $estate_dungeon_location[$estate]
	$place_info['dungeon'] = $interior_dungeon_info[$dungeon]

	$kitchen = 'basic'
	$interior_kitchen_large['basic'] = 'interiors\basic_kitchen_large'
	$interior_kitchen['basic'] = 'interiors\basic_kitchen'
	$interior_kitchen_info['basic'] = '   '
	$bg['kitchen'] = $interior_kitchen[$kitchen]
	$bg['kitchen_lux'] = $interior_kitchen_large[$kitchen]
	$place_name['kitchen'] = $estate_kitchen_name[$estate]
	$place_location['kitchen'] = $estate_kitchen_location[$estate]
	$place_info['kitchen'] = $interior_kitchen_info[$kitchen]

	$lab = 'basic'
	$interior_lab_large['basic'] = 'interiors\basic_lab_large'
	$interior_lab['basic'] = 'interiors\basic_lab'
	$interior_lab_info['basic'] = '   '
	$bg['lab'] = $interior_lab[$lab]
	$bg['lab_lux'] = $interior_lab_large[$lab]
	$place_name['lab'] = $estate_lab_name[$estate]
	$place_location['lab'] = $estate_lab_location[$estate]
	$place_info['lab'] = $interior_lab_info[$lab]

	$boudoir = 'gothic'
	$interior_boudoir_large['gothic'] = 'interiors\gothic_boudoir_large'
	$interior_boudoir['gothic'] = 'interiors\gothic_boudoir'
	$interior_boudoir_info['gothic'] = '   '
	$bg['boudoir'] = $interior_boudoir[$boudoir]
	$bg['boudoir_lux'] = $interior_boudoir_large[$boudoir]
	$place_name['boudoir'] = $estate_boudoir_name[$estate]
	$place_location['boudoir'] = $estate_boudoir_location[$estate]
	$place_info['boudoir'] = $interior_boudoir_info[$boudoir]

	extended_rental_cheat -= 1
end

if master_wealth < 4: club_member = 0

!Added Chimera Gem enhancement - crushboss
if chimera_gem_on = 1: master_excitement = 5 & master_excitement_rate = 200

!Variable rule normalization for assistant - crushboss
!Rules are now properties of the assistant array, so killvar 'assistant' (below) clears them - ImperatorAugustus
!if assistant_state = 0 and assistant['account_rule'] = 1: assistant['account_rule'] = 0
!if assistant_state = 0 and assistant['alchemist_rule'] = 1: assistant['alchemist_rule'] = 0
!if assistant_state = 0 and assistant['cleans_rule'] = 1: assistant['cleans_rule'] = 0
!if assistant_state = 0 and assistant['cooks_rule'] = 1: assistant['cooks_rule'] = 0
!if assistant_state = 0 and assistant['washes_master_rule'] = 1: assistant['washes_master_rule'] = 0
!if assistant_state = 0 and assistant['supervise_rule'] = 1: assistant['supervise_rule'] = 0

!Reset assistant variables if no assistant exists and fix blank screen bug for assistant - crushboss
if assistant_state = CONST_INT['no_slave']: dynamic $clear_slave_instance, 'assistant'

if assistant_state = CONST_INT['slave_exist'] and slave_state = CONST_INT['no_slave']: assistant['alchemist_rule'] = 1

! make overlapping rules mutually exclusive, by removing them from the assistant if the slave has them enabled, and vice versa
! assistant is checked first so that if a slave is removed from cryo who had the rule before, the rule stays with the assistant
! this checks only for rules that are enabled, not rules that are disabled, so it remains possible to disable the rule for both
if assistant_state > CONST_INT['no_slave'] and slave_state > CONST_INT['no_slave']:
	!if assistant['account_rule'] = 1:       slave['account_rule'] = 0
	if assistant['cleans_rule'] = 1:        slave['cleans_rule'] = 0
	if assistant['cooks_rule'] = 1:         slave['cooks_rule'] = 0
	if assistant['washes_master_rule'] = 1: slave['washes_master_rule'] = 0
	if assistant['tentacle_rule'] = 1:      slave['tentacle_rule'] = 0

	!if slave['account_rule'] = 1:           assistant['account_rule'] = 0
	if slave['cleans_rule'] = 1:            assistant['cleans_rule'] = 0
	if slave['cooks_rule'] = 1:             assistant['cooks_rule'] = 0
	if slave['washes_master_rule'] = 1:     assistant['washes_master_rule'] = 0
	if slave['tentacle_rule'] = 1:          assistant['tentacle_rule'] = 0
end

!Disable Vaginal Balls rule if the correct conditions don’t exist - crushboss
!Most of the slave rule conditions are handled in slave_stat but for various reasons this one requires special handling here
if slave['v_balls_rule'] = 1:
	if inventory['vaginal_balls'] < 1 or slave['virginity'] < 1:
		slave['v_balls_rule'] = 0
	end
end

!Fix blank screen bug - crushboss
if $assistant['right_wpn'] = '': $assistant['right_wpn'] = 'безоружный'
if $assistant['left_wpn'] = '': $assistant['left_wpn'] = 'безоружный'
if $assistant['armor'] = '': $assistant['armor'] = 'без_брони'
if $assistant['cloth'] = '': $assistant['cloth'] = 'голая'

!Reset all slave variables when no slave exists - improved - crushboss
if slave_state = CONST_INT['no_slave']:
	dynamic $clear_slave_instance, 'slave'
	success = 0
	angst_rise = 0
	moral_app = 0
	moral_basis = 0
	moral_boost = 0
	slave_fights_back = 0
	slave_escape = 0
	slave_attack = 0
	slave_suicide = 0
	slave_died = 0
	rules_broken_message = 0
	show_slave_fullimage = 0
	cheer_effect = 0
	cheer_rate = 0
	reasoning_effect = 0
	reasoning_rate = 0
	slave_will_masturbate = 0
	slave_masturbating_anyway = 0

	fear_resistance = 0
	rise_difficulty = 0

	futile_threat = 0

	slave_beg_for_sex = 0
	killvar 'slave_specialisation'
	!Do not enable - bug fix - crushboss
	! killvar 'sex'
end

!Fix blank screen bug - crushboss
if $slave['right_wpn'] = '': $slave['right_wpn'] = 'безоружный'
if $slave['left_wpn'] = '': $slave['left_wpn'] = 'безоружный'
if $slave['armor'] = '': $slave['armor'] = 'без_брони'
if $slave['cloth'] = '': $slave['cloth'] = 'голая'

!handle accumulated half actions - ImperatorAugustus
if master_half_action > 1: master_half_action -= 2 & dynamic $master_energy_drop
if slave['half_action'] > 1: slave['half_action'] -= 2 & dynamic $slave_energy_drop
if prisoner['half_action'] > 1: prisoner['half_action'] -= 2 & dynamic $prisoner_energy_drop
if assistant['half_action'] > 1: assistant['half_action'] -= 2 & dynamic $assistant_energy_drop
if cow['half_action'] > 1: cow['half_action'] -= 2 & dynamic $cow_energy_drop

!counting home prestige
house_prestige = estate_prestige[$estate] + interior_prestige[$study] + interior_prestige[$bed] + interior_prestige[$bath] + interior_prestige[$kitchen]

if raven_crown_on = 1: auspex = 1

!Added bull ring enhancement - crushboss (infinite energy disabled, see $master_energy_drop -ImperatorAugustus)
!if bull_ring_on = 1 and master_energy < 1: master_energy = 1

!Not sure why the line below is needed - crushboss (that line was to prevent assistants from receiving bonuses from items the slave is wearing, in addition to the items the assistant is wearing - ImperatorAugustus)
!assistant_item = 0 &! but it is not needed now - ImperatorAugustus

! update house mess before updating slaves and master whose mood may be affected (relocated from $calculate_attributes)
house_mess = 0
if house_mess_rate >= house_mess_rate_cap[0]: house_mess = 1
if house_mess_rate >= house_mess_rate_cap[1]: house_mess = 2
if house_mess_rate >= house_mess_rate_cap[2]: house_mess = 3
if house_mess_rate >= house_mess_rate_cap[3]: house_mess = 4
if house_mess_rate >= house_mess_rate_cap[4]: house_mess = 5
if house_mess_rate < 0: house_mess_rate = 0

! update slave, assistant, prisoner and cow (slaves who are visible on the main screen)
dynamic $do_for_each_slave_in_list, '$newloc_update_slave', '$main_screen_slave_characters' &! see #static_base (includes $set_obedience_difficulty and $slave_price)
gs '$slave_traits' &! check for revealed traits and refresh trait features list for slave, assistant, prisoner, cow

!TRAITS OF FROZEN SLAVES
if code_defined['newloc_update_iced_features_list'] = 0:
	code_defined['newloc_update_iced_features_list'] = 1 &! do-once

	$newloc_update_iced_features_list = {
		$dynslave_features_list = ''
		if dynslave_state ! CONST_INT['no_slave']:
			if dynslave['brand'] = 0: $dynslave_features_list +='Not branded
'
			if dynslave['wounds'] > 0: $dynslave_features_list += $wounds[dynslave['wounds']] + '
'
			if dynslave['scars'] > 0: $dynslave_features_list += $scars[dynslave['scars']] + '
'
			if dynslave['bruises'] > 0: $dynslave_features_list += $bruises[dynslave['bruises']] + '
'
			if dynslave['rehabilitation'] > 0: $dynslave_features_list += 'Recovery [<<dynslave[''rehabilitation'']>>]
'
			if dynslave['virginity'] < 2: $dynslave_features_list += 'Virgin
'
			if dynslave['fertility'] = -2: $dynslave_features_list += 'Immature
'
			if dynslave['fertility'] = -1: $dynslave_features_list += 'Sterile
'
			if dynslave['fertility'] = 1: $dynslave_features_list += 'Egglaying
'
			if dynslave['pregnant'] > 0 and dynslave['pregnant_revealed'] > 0: $dynslave_features_list += 'Pregnant
'
			if dynslave['arena_level'] > 4: $dynslave_features_list += 'Arena champion
'
		end
	}
end

dynamic $do_for_each_slave_in_list, '$newloc_update_iced_features_list', '$iced_slave_characters'

gs '$calculate_attributes' &! update master stats including energy and mood, should be done after updating slaves due to dependencies - ImperatorAugustus

восприятие = master_fighter - 1
ловкость = master_fighter - 1
сила = master_fighter - 1

!Update variables for displaying stats that range from negative to positive (neutral to positive use indices 0-5, negative use indices 6-10)
master_mood_plus = IIF(master_mood < 0, 5 - master_mood, master_mood)
master_excitement_plus = IIF(master_excitement < 0, 5 - master_excitement, master_excitement)

slave_mood_plus = IIF(slave['mood'] < 0, 5 - slave['mood'], slave['mood'])
slave_arousal_plus = IIF(slave['arousal'] < 0, 5 - slave['arousal'], slave['arousal'])

assistant_mood_plus = IIF(assistant['mood'] < 0, 5 - assistant['mood'], assistant['mood'])
assistant_arousal_plus = IIF(assistant['arousal'] < 0, 5 - assistant['arousal'], assistant['arousal'])

if cooked_food < 0: cooked_food_plus = 0
if cooked_food > 0: cooked_food_plus = cooked_food

!calculation of fridge free 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
if spawn_semen > estate_size[$estate]: spawn_semen = estate_size[$estate]

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

if exam_in_progress = 1:
	if sparks <= 0:
		txt = 1
		lecture = 13
		gt 'demo_intro'
	end
end

!Reflagging full piercing - crushboss
if slave['nipple_piercing'] = 1 and slave['clit_piercing'] = 1 and slave['ear_piercing'] = 1 and slave['tongue_piercing'] = 1 and slave['belly_piercing'] = 1 and slave['nostril_piercing'] = 1 and slave['nose_piercing'] = 1:
	slave['full_piercing'] = 1
	if slave['piercings'] < 7: slave['piercings'] = 7
	if slave['piercing_count'] < 4: slave['piercing_count'] = 4
end
if assistant['nipple_piercing'] = 1 and assistant['clit_piercing'] = 1 and assistant['ear_piercing'] = 1 and assistant['tongue_piercing'] = 1 and assistant['belly_piercing'] = 1 and assistant['nostril_piercing'] = 1 and assistant['nose_piercing'] = 1:
	assistant['full_piercing'] = 1
	if assistant['piercings'] < 7: assistant['piercings'] = 7
	if assistant['piercing_count'] < 4: assistant['piercing_count'] = 4
end

!Patrician quest adjustments - crushboss
if faction_fame['serpis'] >= 5 and npc_progress['serpis_prince_first'] ! 2: faction_fame['serpis'] = 4
if faction_fame['taurus'] >= 5 and npc_progress['taurus_king'] ! 2: faction_fame['taurus'] = 4
if faction_fame['kamira'] >= 5 and npc_progress['tiamath'] ! 2: faction_fame['kamira'] = 4
if faction_fame['korvus'] >= 5 and npc_progress['korvus_knyaz'] ! 2: faction_fame['korvus'] = 4

!Testing code - crushboss
if cheat_k = 1 or cheat_h = 1 or cheat_j = 1:
	slave['rehabilitation'] = 0
	assistant['rehabilitation'] = 0
end
!end of testing code - crushboss

--- $newloc ---------------------------------


code:
# $objsel
!Location handler objects

if $selobj = '@':
	!
	!if slave_fights_back = 1:
	!	gt 'slave_fights_back'
	!end
	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
		killvar '$text'
		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
end

if $selobj = '':
	unsel
	killobj
	if sound_on = 1: play 'content/snd/page_right.wav', sound_volume
	txt_count = arrsize('$text') - 1
	if txt < txt_count:
		txt += 1
	else
		if $msg_txt ! '' and txt_count = txt:
			msg '<<$msg_txt>>'
			$msg_txt = ''
		end
		killvar '$text'
		if $return_lock ! '':
			gt $return_lock
		elseif exam_in_progress = 1:
			gt 'demo_menu_form'
		elseif is_home ! 1:
			gt 'city_menu_form'
		else
			gt 'menu_form'
		end
	end
	gt $curloc
end

if $selobj = '':
	unsel
	killobj
	if sound_on = 1: play 'content/snd/page_left.wav', sound_volume
	txt -= 1
	gt $curloc
end

if $selobj = '':
	unsel
	killobj
	if sound_on = 1: play 'content/snd/page_right.wav', sound_volume
	txt_count = arrsize('$text') - 1
	if txt < txt_count:
		txt += 1
	else
		if $msg_txt ! '' and txt_count = txt:
			msg '<<$msg_txt>>'
			$msg_txt = ''
		end
		killvar '$text'
		gt 'demo_menu_form'
	end
	gt $curloc
end

if $selobj = '':
	unsel
	killobj
	if sound_on = 1: play 'content/snd/page_left.wav', sound_volume
	txt -= 1
	gt $curloc
end

if $selobj = '':
	unsel
	killobj
	if sound_on = 1: play 'content/snd/page_right.wav', sound_volume
	txt_count = arrsize('$text') - 1
	if txt < txt_count:
		txt += 1
	else
		killvar '$text'
		lecture = 100
		txt = 1
	end
	gt $curloc
end

if $selobj = '':
	unsel
	killobj
	gt 'slave_auction_pass'
end

--- $objsel ---------------------------------


code:
# $ongload
!Game load handler (will run after game state is loaded)

saved_game_loaded = 1 &! do-once flag for $newloc

if $curloc = 'main_screen': gt 'menu_form'
if $curloc = 'city_screen': gt 'city_menu_form'

--- $ongload ---------------------------------


code:
# $quest_list
!create a list for active quests
$quest_list = ''

n = arrsize('$quest')
i = 0
:loop
	if active[$quest[i]] = 1: $quest_list += '<<$quest[i]>>

'
	i += 1
if i < n: jump 'loop'

if is_perv > 1 and no_loli ! 1:
	if (assistant_state < CONST_INT['slave_exist'] or assistant['age'] ! CONST_INT['loli_age'] or assistant['beauty'] < 3):  $quest_list += 'Being a dirty old man, it would be adorable to have a very young, pretty assistant

'
	! this should not show up as an objective if you have a fainted loli assistant, so the state check is < exist (which means: either no slave or dead) - ImperatorAugustus

	if loli_magic < 2 and (assistant_state > CONST_INT['no_slave'] and assistant['age'] = CONST_INT['loli_age'] and assistant['beauty'] > 2):
		$quest_list += 'Being a dirty old man, it would be adorable to have another very young, pretty slave

'

		if $estate ! 'white_house' and $estate ! 'korvus_house' and $estate ! 'taurus_house':
			$quest_list += 'Being a dirty old man, it would be adorable to have more room for young, pretty slaves

'
		end
	end
end

if quest_description_mode = 1: $quest_list = '   <<$quest_description[choosen_quest]>>'
--- $quest_list ---------------------------------


code:
# $ride_finish
!end of the chariot race
CLOSE ALL
ride_count = 10
sp_txt = 0

!Creating a route to the next race
$trace[1] = 'ride_start'
i = 1
:loop
	i += 1
	a = rand(1,12)
	$trace[i] = $trace_type[a]
if i < 11: jump 'loop'

$trace[12] = 'ride_finish'

!Racehorse injuries
a = slave['stamina'] - chariot['pony_health']
if a > 0:
	b = rand(11,59)
	slave_rate['wounds'] += b
end
slave['energy'] = -3
pony_dead = 0
if chariot['pony_health'] = 0:
!CHECK: почему no_slave а не slave_dead?
	dynamic $clear_slave_instance, 'slave'
	pony_dead = 1
	sparks += 5
end

!1 =  chariot broke
if args[0] = 1:
	interaction_city = 121
	gt 'interaction_city'
end

!2 = wheel flew off
if args[0] = 2:
	interaction_city = 121
	gt 'interaction_city'
end

!3 = steed fell
if args[0] = 3:
	interaction_city = 123
	gt 'interaction_city'
end

!4 = reached the the finish line
if args[0] = 4:
	$race_winner = $participant[1]
	interaction_city = 124
	if $race_winner = 'master':
		race_win_ratio += 1
		slave_rate['fame'] += 11
		if brand_reputation < 4: brand_rate += 5
		master_moodlet['pos_master_winner'] += 3
		master_moodlet['neg_master_loser'] = 0
		slave['pos_slave_winner'] += slave['sensitivity']
		slave['neg_slave_loser'] = 0
		slave_rate['stamina'] += 10
		slave_rate['temper'] += 10
		slave_rate['instinct'] += 10
		slave_rate['dressage'] += 25
		if slave['mood'] > 0: slave_rate['moral'] += 5
		slave['virtue'] = 5
		slave['sin'] = 0
		slave['has_ride_win'] += 1
	else
		race_win_ratio -= 1
		slave_rate['fame'] += 1
		brand_rate -= 1
		master_moodlet['pos_master_winner'] = 0
		master_moodlet['neg_master_loser'] += 3
		slave['neg_slave_loser'] += slave['sensitivity']
		slave['pos_slave_winner'] = 0
		slave_rate['stamina'] += 5
		slave_rate['pride'] -= 5
		slave_rate['temper'] += 5
		slave_rate['instinct'] += 2
		slave_rate['dressage'] += 10

		slave['virtue'] = 0
		dynamic $sin_gained_now, 'slave'
	end
	gt 'interaction_city'
end

--- $ride_finish ---------------------------------


code:
# $ride_start
!Preparation for chariot race
!Overhauled by crushboss

$place = 'chariot_race' &! used in menu_form to intercept ESC key-press during race

CLOSE ALL
pony_gear_bonus = 0

!Dressage, meekness, and courage affinity revealed - crushboss
if slave['dressage_affinity_revealed'] = 0: slave['dressage_affinity_revealed'] = 1
if slave['meekness_revealed'] = 0: slave['meekness_revealed'] = 1
if slave['courage_revealed'] = 0: slave['courage_revealed'] = 1

gs '#chariots_base'
chariot['weight'] = (heavy_frame + heavy_boards + heavy_chassis + heavy_wheels + heavy_rider_armor) + 5
chariot['pony_health'] = (slave['stamina'] + slave['dressage_affinity'])
chariot['maneuverability'] = (slave['instinct'] + slave['dressage'] + (slave['dressage_affinity']*2))
if slave['meekness'] < 0: chariot['maneuverability'] -= 1
if slave['meekness'] > 0: chariot['maneuverability'] += 1
if slave['courage'] < 0: chariot['maneuverability'] -= 1
if slave['courage'] > 0: chariot['maneuverability'] += 1
if slave['pride'] > 2: chariot['maneuverability'] -= 1
if slave['temper'] < 4: chariot['maneuverability'] -= 1
if slave['energy'] < 3: chariot['maneuverability'] -= 1

!Added modifiers based on age - crushboss
if slave['age'] = CONST_INT['loli_age']: chariot['maneuverability'] += 2
if slave['age'] = CONST_INT['milf_age']: chariot['maneuverability'] -= 2

!Added modifiers based on pony gear equipped - crushboss
if $slave['headband'] = 'pony_plume': pony_gear_bonus += 1
if $slave['cloth'] = 'anal_tail': pony_gear_bonus += 1
if $slave['boots'] = 'hoofed_boots': pony_gear_bonus += 1
if $slave['gloves'] = 'ponygirl_harness': pony_gear_bonus += 1

!Added message so players will get used to equipping pony gear - otherwise they will mostly lose and get frustrated - crushboss
msg 'Pony Gear Bonus: <<pony_gear_bonus>>
A bonus of 2 or less results in a penalty
Pony Gear available:
Plumed Bridle
Anal Tail
Hoofed Boots
Pony Harness
'

!Penalty applied if the slave isn’t wearing pony gear - crushboss
if pony_gear_bonus < 3:
	chariot['maneuverability'] -= 2
	chariot['weight'] += 2
end

!Added bonus for dressage affinity - natural pony girls are less affected by chariot weight - crushboss
if slave['dressage_affinity'] > 0: chariot['weight'] -= 2

chariot['speed'] = 0
chariot['max_speed'] = (slave['temper'] + chariot['pony_health']*3) - chariot['weight']
if slave['age'] ! CONST_INT['loli_age']: chariot['max_speed'] = chariot['max_speed']*2
if slave['age'] = CONST_INT['loli_age']: chariot['max_speed'] = ((chariot['max_speed']*3)/2)
chariot['acceleration'] = chariot['max_speed']/4
if chariot['acceleration'] < 1: chariot['acceleration'] = 1
chariot['inertia'] = max(1, (chariot['speed'] * chariot['weight'])/25)
chariot['maneuverability_effective'] = max(0, chariot['maneuverability'] - chariot['inertia'])

slave['calories'] -= 6
slave_rate['hygiene'] += 50
master_hygiene_rate += 30

frame = IIF(heavy_frame = 1, 2, 1)
boards = IIF(heavy_boards = 1, 2, 1)
chassis = IIF(heavy_chassis = 1, 2, 1)
wheels = IIF(heavy_wheels = 1, 2, 1)

$current_ride = $trace_forward_description['ride_start']

killvar 'speed_points'
trace_segment = 1

!$BACKIMAGE = 'content/pic/bg_fight.png'
!new super image by XxX_dark-youba-pojeeratyel'-tvoyei-pees'ki-the_vm-\|-_-_-^__^-_-_-|/MLG_PRO_YOLO#2014_RUS99N4giB4T0R_XxX
!self-explanatory
if ui_style = 1:$backimage = 'content/pic/ui/old/bg_fight_old.png'
if ui_style = 2:$backimage = 'content/pic/ui/grimdark/bg_ride.png'
if ui_style = 0:$backimage = 'content/pic/ui/classic/bg_ride.png'

MSG_X = 350

$future_ride = $trace_forward_description[$trace[2]]

!DEFINE RIVALS
killvar 'rider_participates'
killvar 'speed_points'

e = 0
b = 0
:loop1
	e += 1
	b = rand(2,7)
	if rider_participates[$rider[b]] = 0:
 		rider_participates[$rider[b]] = 1
	else
 		e -= 1
	end
if e < 5: jump 'loop1'

rider_participates['master'] = 1
$rider_ava['master'] = '<<$master_ava_color>>'
$rider_name['master'] = '<<$master_name>>'

gt 'ride_interface'
--- $ride_start ---------------------------------


code:
# $sex_newloc
!Переход на новую локацию при сексе

!'АРХИВ
sex['girl_excitement_state'] = 0
if sex['girl_excitement'] >= 5: sex['girl_excitement_state'] = 1
if sex['girl_excitement'] >= 10: sex['girl_excitement_state'] = 2
if sex['girl_excitement'] >= 25: sex['girl_excitement_state'] = 3
if sex['girl_excitement'] >= 50: sex['girl_excitement_state'] = 4
if sex['girl_excitement'] >= 100: sex['girl_excitement_state'] = 5

sex['girl_attention_state'] = 0
if sex['girl_attention'] >= 5: sex['girl_attention_state'] = 1
if sex['girl_attention'] >= 10: sex['girl_attention_state'] = 2
if sex['girl_attention'] >= 25: sex['girl_attention_state'] = 3
if sex['girl_attention'] >= 50: sex['girl_attention_state'] = 4
if sex['girl_attention'] >= 100: sex['girl_attention_state'] = 5

sex['girl_disgust_state'] = 0
if sex['girl_disgust'] >= 5: sex['girl_disgust_state'] = 1
if sex['girl_disgust'] >= 10: sex['girl_disgust_state'] = 2
if sex['girl_disgust'] >= 25: sex['girl_disgust_state'] = 3
if sex['girl_disgust'] >= 50: sex['girl_disgust_state'] = 4
if sex['girl_disgust'] >= 100: sex['girl_disgust_state'] = 5

sex['girl_openmind_state'] = 0
if sex['girl_openmind'] >= 5: sex['girl_openmind_state'] = 1
if sex['girl_openmind'] >= 10: sex['girl_openmind_state'] = 2
if sex['girl_openmind'] >= 25: sex['girl_openmind_state'] = 3
if sex['girl_openmind'] >= 50: sex['girl_openmind_state'] = 4
if sex['girl_openmind'] >= 100: sex['girl_openmind_state'] = 5

sex['girl_pain_state'] = 0
if sex['girl_pain'] >= 5: sex['girl_pain_state'] = 1
if sex['girl_pain'] >= 10: sex['girl_pain_state'] = 2
if sex['girl_pain'] >= 25: sex['girl_pain_state'] = 3
if sex['girl_pain'] >= 50: sex['girl_pain_state'] = 4
if sex['girl_pain'] >= 100: sex['girl_pain_state'] = 5'
--- $sex_newloc ---------------------------------


code:
# $slave_price
!Slave Price Calculation
!Overhauled by crushboss
!Converted to dynamic and merged with $slave_price_stock and $assistant_rank_stats - ImperatorAugustus

if $args[0] = '': $args[0] = 'slave' &! update slave if not specified - ImperatorAugustus

dynamic $replace($update_slave_price, 'dyn'+'slave', $args[0]) &! see #static_base

--- $slave_price ---------------------------------


code:
# $slave_traits
!reveals slave traits

dynamic $do_for_each_slave_in_list, '$check_slave_for_revealed_traits', '$main_screen_slave_characters' &! see #static_base
dynamic $do_for_each_slave_in_list, '$update_slave_features_list', '$main_screen_slave_characters' &! see #static_base

--- $slave_traits ---------------------------------


code:
# $stock_traits
!reveals stock traits
!only list traits that would be apparent from visual inspection or reputation - ImperatorAugustus

!Stock Traits
$stock_features_list = ''
sanity = stock['ego'] + stock['temper'] + stock['pride']
if sanity < 3:
	$stock_features_list += 'Sanity
'
elseif sanity < 5:
	$stock_features_list += 'Sanity
'
end
!if stock['brand'] = 0:  $stock_features_list += 'Not Branded
'
if stock['wounds'] > 0:  $stock_features_list += '<<$wounds[stock["wounds"]]>>
'
if stock['scars'] > 0:   $stock_features_list += '<<$scars[stock["scars"]]>>
'
if stock['bruises'] > 0: $stock_features_list += '<<$bruises[stock["bruises"]]>>
'
if cheat_no_starve = 0 and master_medic >= 4:
	if stock['days_without_food'] = 0 and stock['neg_hungry'] > 0:
		$stock_features_list += '<<$starvation[1]>>
'
	elseif stock['days_without_food'] = 1:
		$stock_features_list += '<<$starvation[2]>>
'
	elseif stock['days_without_food'] = 2:
		$stock_features_list += '<<$starvation[3]>>
'
	elseif stock['days_without_food'] = 3 or stock['days_without_food'] < 0:
		$stock_features_list += '<<$starvation[4]>>
'
	elseif stock['days_without_food'] > 3:
		$stock_features_list += '<<$starvation[5]>>
'
	end
end
if stock['rehabilitation'] > 0: $stock_features_list += 'Recovery [<<stock["rehabilitation"]>>]
'
if stock['virginity'] < 2: $stock_features_list += 'Virgin
'
if stock['grace'] > 0: $stock_features_list += 'Graceful
'
if stock['grace'] < 0: $stock_features_list += 'Klutzy
'
if stock['dexterity'] > 0: $stock_features_list += 'Dexterous
'
if stock['dexterity'] < 0: $stock_features_list += 'Clumsy
'
if stock['arena_level'] > 8:
	$stock_features_list += 'Arena Grand Champion
'
elseif stock['arena_level'] > 4:
	$stock_features_list += 'Arena Champion
'
end
!if stock['fertility'] = -2: $stock_features_list += 'Immature
'

--- $stock_traits ---------------------------------


code:
# $weapon_assignments
!Weapon Assignments - crushboss

!TAKE OUT THE WEAPONS

!Master/Slaver Weapons
$за_спиной = $master_back_wpn
$слева = $master_left_wpn
$справа = $master_right_wpn
$предплечье = $master_arm_wpn
$в_сапоге = $master_leg_wpn

if combatant = 1:
	$за_спиной = $slave["back_wpn"]
	$слева = $slave["left_wpn"]
	$справа = $slave["right_wpn"]
	$предплечье = $slave["arm_wpn"]
	$в_сапоге = $slave["leg_wpn"]
end

if combatant = 2:
	$за_спиной = $assistant["back_wpn"]
	$слева = $assistant["left_wpn"]
	$справа = $assistant["right_wpn"]
	$предплечье = $assistant["arm_wpn"]
	$в_сапоге = $assistant["leg_wpn"]
end

--- $weapon_assignments ---------------------------------


code:
# Start
! EVERYTHING BELOW SHOULD BE REPLICATED IN start_refresh

killall &! THIS DELETES EVERY VARIABLE IN THE GAME

usehtml = 1
debug = 0
sound_on = 1
music_volume = 100
sound_volume = 100

SHOWOBJS 0
SHOWACTS 0
SHOWINPUT 0
SHOWSTAT 0

INTEGRATED_ACTIONS = 1
HIDE_SCROLL_ARROWS = 1
DISABLESCROLL = 1

$FNAME = 'Consolas'

! END OF REPLICATED SECTION FOR start_refresh
! THERE SHOULD BE NOTHING BELOW EXCEPT gt 'main_menu'
gt 'main_menu'

--- Start ---------------------------------


code:
# _layout
!layout of a main game screen
INTEGRATED_ACTIONS = 0
if ui_style = 1:$backimage = 'content/pic/ui/old/bg_old.png'
if ui_style = 2:$backimage = 'content/pic/ui/grimdark/bg.png'
if ui_style = 0:$backimage = 'content/pic/ui/classic/bg.png'

SHOWOBJS 1
SHOWSTAT 0
SHOWACTS 0

!$onnewloc = '$newloc'

LCOLOR = rgb(0,0,255)
FCOLOR = rgb(0,0,0)

$MAINDESC_BACKIMAGE = ''
! removed non-existent path 'content/.png' -ImperatorAugustus
MAINDESC_X = 1
MAINDESC_Y = 1
MAINDESC_W = 1280
MAINDESC_H = 800

$MSG_BACKIMAGE = 'content\pic\msg_bg.png'
$MSG_OK_IMAGE = 'content/pic/buttons/ok-icon.png'
$MSG_FORMAT = '
%TEXT%
'
MSG_TEXT_X = 80
MSG_TEXT_Y = 40
MSG_TEXT_W = 370
MSG_TEXT_H = 400
MSG_OK_X = 250
MSG_OK_Y = 340
MSG_X = 200

$STATDESC_BACKIMAGE = ''
! removed non-existent path 'content/.png' -ImperatorAugustus
STATDESC_X = 810
STATDESC_Y = 1
STATDESC_W = 450
STATDESC_H = 800

$OBJECTS_BACKIMAGE = ''
! removed non-existent path 'content/c.png' -ImperatorAugustus
OBJECTS_X = 780
OBJECTS_Y = 660
OBJECTS_W = 50
OBJECTS_H = 100
--- _layout ---------------------------------